in reply to Proc::Daemon and Log::Log4perl
Looking at the source code of Proc::Daemon, the relevant code has potential for failures but doesn't check the results:
sub Init { my $oldmode = shift || 0; my($pid, $sess_id, $i); ## Fork and exit parent if ($pid = Fork) { exit 0; } ## Detach ourselves from the terminal croak "Cannot detach from controlling terminal" unless $sess_id = POSIX::setsid(); ## Prevent possibility of acquiring a controling terminal if (!$oldmode) { $SIG{'HUP'} = 'IGNORE'; if ($pid = Fork) { exit 0; } } ## Change working directory chdir "/"; ## Clear file creation mask umask 0; ## Close open file descriptors foreach $i (0 .. OpenMax) { POSIX::close($i); } ## Reopen stderr, stdout, stdin to /dev/null open(STDIN, "+>/dev/null"); open(STDOUT, "+>&STDIN"); open(STDERR, "+>&STDIN"); $oldmode ? $sess_id : 0; }
There are a couple of possibilities for you to check:
For more debugging information, you should maybe reopen STDERR to a log file to which you warn (instead of using Log::Log4Perl) - I expect some print to closed file handle messages here.
|
|---|