From 449af292dc48b89e266c2a74c8110947c3db2ae2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 10 Sep 2009 10:25:57 +0200 Subject: tests:webserver: reopen STDOUT/STDERR after locking pid file. Michael --- tests/scripts/webserver.pl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/scripts/webserver.pl b/tests/scripts/webserver.pl index a1d171d..ac029bd 100755 --- a/tests/scripts/webserver.pl +++ b/tests/scripts/webserver.pl @@ -154,10 +154,6 @@ sub daemonize() { chdir "/" or die "daemonize: can't chdir to /: $!"; open STDIN, "/dev/null" or 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(); 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: $!"; } +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() { open LOCKFILE, "> $pid_file" or die "Error opening pid-file $pid_file: $!"; @@ -191,8 +194,8 @@ $|=1; # autoflush process_options(); daemonize(); - get_pid_lock(); +reopen_logs(); $SIG{CHLD} = \&REAPER; -- cgit v1.2.3