tests:webserver: reopen STDOUT/STDERR after locking pid file.

Michael
This commit is contained in:
Michael Adam 2009-09-10 10:25:57 +02:00
parent 526c70f687
commit 449af292dc

View File

@ -154,10 +154,6 @@ sub daemonize() {
chdir "/" or die "daemonize: can't chdir to /: $!"; chdir "/" or die "daemonize: can't chdir to /: $!";
open STDIN, "/dev/null" or open STDIN, "/dev/null" or
die "daemonize: Can't read from /dev/null: $!"; die "daemonize: Can't read from /dev/null: $!";
open STDOUT, ">> $access_log_file" or
die "daemonize: Can't write to '$access_log_file': $!";
open STDERR, ">> $error_log_file" or
die "daemonize: Can't write to '$error_log_file': $!";
my $pid = fork(); my $pid = fork();
die "daemonize: can't fork: $!" if not defined($pid); die "daemonize: can't fork: $!" if not defined($pid);
@ -167,6 +163,13 @@ sub daemonize() {
setsid or die "damonize: Can't create a new session: $!"; setsid or die "damonize: Can't create a new session: $!";
} }
sub reopen_logs() {
open STDOUT, ">> $access_log_file" or
die "daemonize: Can't write to '$access_log_file': $!";
open STDERR, ">> $error_log_file" or
die "daemonize: Can't write to '$error_log_file': $!";
}
sub get_pid_lock() { sub get_pid_lock() {
open LOCKFILE, "> $pid_file" or open LOCKFILE, "> $pid_file" or
die "Error opening pid-file $pid_file: $!"; die "Error opening pid-file $pid_file: $!";
@ -191,8 +194,8 @@ $|=1; # autoflush
process_options(); process_options();
daemonize(); daemonize();
get_pid_lock(); get_pid_lock();
reopen_logs();
$SIG{CHLD} = \&REAPER; $SIG{CHLD} = \&REAPER;