This code was borrowed from Stevens' "Unix Network Programming" - a book that should be in every programmers bookshelf...sub daemonize { my $childpid; if(($childpid = fork()) < 0) { die("can't fork: $!"); } elsif($childpid > 0) { exit(0); # parent - exits } (setpgrp() != -1) || die("Can't change process group: $!"); $SIG{HUP} = 'IGNORE'; if(($childpid = fork()) < 0) { die("can't fork: $!"); } elsif($childpid > 0) { exit(0); # parent - exits } chdir("/"); umask(0); }
Michael
In reply to Re: Re: Leave it running
by mpeppler
in thread Leave it running
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |