From: Stevan Little Date: Wed, 5 Dec 2007 02:33:06 +0000 (+0000) Subject: tweaking for FCGI stuff X-Git-Tag: 0_06~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Daemonize.git;a=commitdiff_plain;h=3c0d959792df32916a58cefeb29185715b9db51b tweaking for FCGI stuff --- diff --git a/lib/MooseX/Daemonize/Core.pm b/lib/MooseX/Daemonize/Core.pm index 5447f63..3b76782 100644 --- a/lib/MooseX/Daemonize/Core.pm +++ b/lib/MooseX/Daemonize/Core.pm @@ -51,12 +51,14 @@ sub daemon_detach { chdir '/'; # change to root directory umask 0; # clear the file creation mask - # get the max numnber of possible file descriptors - my $openmax = POSIX::sysconf( &POSIX::_SC_OPEN_MAX ); - $openmax = 64 if !defined($openmax) || $openmax < 0; + unless ($options{dont_close_all_files}) { + # get the max numnber of possible file descriptors + my $openmax = POSIX::sysconf( &POSIX::_SC_OPEN_MAX ); + $openmax = 64 if !defined($openmax) || $openmax < 0; - # close them all - POSIX::close($_) foreach (0 .. $openmax); + # close them all + POSIX::close($_) foreach (0 .. $openmax); + } # fixup STDIN ... @@ -77,7 +79,7 @@ sub daemon_detach { # fixup STDERR ... if (my $stderr_file = $ENV{MX_DAEMON_STDERR}) { - open STDERR, ">", "ERR.txt" + open STDERR, ">", $stderr_file or confess "Could not redirect STDERR to $stderr_file : $!"; } else { @@ -203,6 +205,8 @@ directory then simply change it later in your daemons code. =item Closes all open file descriptors. +See below for information on how to change this part of the process. + =item Reopen STDERR, STDOUT & STDIN to /dev/null This behavior can be controlled slightly though the MX_DAEMON_STDERR @@ -226,6 +230,12 @@ found above, and by Googling "double fork daemonize". If you the double-fork behavior off, you might want to enable the I behavior in the C method. +=item I + +Setting this option to true will cause it to skip closing all the +filehandles, this is useful if you are opening things like sockets +and such in the pre-fork. + =back B