From: <buc...@us...> - 2011-01-11 13:41:54
|
Revision: 188 http://devmon.svn.sourceforge.net/devmon/?rev=188&view=rev Author: buchanmilne Date: 2011-01-11 13:41:47 +0000 (Tue, 11 Jan 2011) Log Message: ----------- Open the log file before daemonize so stderr is still open to report if opening the log file fails, but re-open the log file in daemonize Modified Paths: -------------- trunk/modules/dm_config.pm Modified: trunk/modules/dm_config.pm =================================================================== --- trunk/modules/dm_config.pm 2010-11-30 11:35:45 UTC (rev 187) +++ trunk/modules/dm_config.pm 2011-01-11 13:41:47 UTC (rev 188) @@ -268,12 +268,12 @@ # Dont daemonize if we are printing messages $g{'daemonize'} = 0 if $g{'print_msg'}; + # Open the log file + open_log(); + # Daemonize if need be daemonize(); - # Open the log file - open_log(); - # Set our pid $g{'mypid'} = $$; @@ -1012,14 +1012,14 @@ return if $g{'logfile'} =~ /^\s*$/ or !$g{'daemonize'}; $g{'log'} = new IO::File $g{'logfile'}, 'a' - or log_fatal("Unable to open logfile! ($!)",0); + or log_fatal("ERROR: Unable to open logfile $g{'logfile'} ($!)",0); $g{'log'}->autoflush(1); } # Allow Rotation of log files sub reopen_log { my ($signal) = @_; - do_log("Received signal $signal, closing and re-opening log file",3); + do_log("Received signal $signal, closing and re-opening log file",3) if $signal; if (defined $g{'log'}) { undef $g{'log'}; &open_log; @@ -2062,6 +2062,9 @@ $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = \&quit; $SIG{HUP} = \&reopen_log; + # Re-open the log file to ensure file descriptors are right + reopen_log(); + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |