in reply to Fork issues
sub daemonize { # usage: daemonize( [errorlog path, activitylog path] ) my $errlog=shift; my $actlog=shift; $errlog ||="/dev/null"; $actlog ||="/dev/null"; chdir '/' or die "can't chdir to root : $!"; open( STDIN, '</dev/null' ) or die "can't redirect STDIN : $!"; open( STDERR, ">>$errlog" ) or die "can't redirect STDERR : $!"; open( STDOUT, ">>$actlog" ) or die "can't redirect STDOUT : $!"); fork and exit; return 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fork issues
by alexm (Chaplain) on Feb 13, 2008 at 16:40 UTC |