in reply to Proc::Daemon not detaching
Daemonizing isn't hard but the source code for Proc::Daemon sure makes it look hard. My searching for daemonize didn't find anything simpler. Maybe there is a bug hidden in that complexity. Just keep it simple?
use POSIX 'setsid'; $SIG{HUP} = 'IGNORE'; #chdir('/') # Not required in your case; maybe not desired. # or die "Can't cd /: $!\n"; for( 1,0 ) { my $pid = fork(); die "Can't fork: $!\n" if ! defined $pid; exit if $pid; if( $_ && -1 == setsid() ) { die "Can't setsid: $!\n"; } } open STDIN, '<', '/dev/null' or die "STDIN: $!\n"; open STDOUT, '>', '/dev/null' or die "STDOUT: $!\n"; open STDERR, '>&', \*STDOUT or die "STDERR: $!\n";
At least that will split the difference as to if the problem is a bug in daemonization when you use that module in that way.
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Proc::Daemon not detaching (KISS)
by Dave Howorth (Scribe) on Mar 20, 2014 at 15:08 UTC |