perlplexer has asked for the wisdom of the Perl Monks concerning the following question:
On HPUX 11, Perl 5.6.1, this sub wait()s for the daemon to finish as if it was still a normal child process. And I know that setsid() succeeded since parent keeps wait()ing for 100 seconds.daemon(); sub daemon{ # Create a daemon which does nothing but "sleep 100" my $dpid = fork(); return 0 unless defined $dpid; unless ($dpid){ exit 255 unless open STDIN, '/dev/null'; exit 255 unless open STDOUT, '>/dev/null'; exit 255 unless open STDERR, '>/dev/null'; exit 255 unless setsid(); sleep 100; exit 0; } return 0 unless wait() == -1; return $dpid; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: setsid() and complete (?) dissociation of child from parent
by Abigail-II (Bishop) on Mar 03, 2003 at 01:07 UTC | |
by perlplexer (Hermit) on Mar 03, 2003 at 01:31 UTC | |
|
Re: setsid() and complete (?) dissociation of child from parent (more fork)
by tye (Sage) on Mar 03, 2003 at 19:57 UTC |