----- Original Message ----- From: "Chris Dillon" <[EMAIL PROTECTED]> To: "Lee Nelson" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, November 25, 2002 6:23 PM Subject: Re: Apache not killing subprocesses, only on FreeBSD
> On Sun, 24 Nov 2002, Lee Nelson wrote: > > > myprogram.pl reads a few parameters from STDIN, and then > > forks to work in the background: I daemonize as follows: chdir ('/') || exit 1; open STDIN, '/dev/null'; open STDOUT, '>/dev/null'; if (my $pid = fork ()) { open (PID, '>/var/run/my-prog.pid') || exit 1; flock (PID, 2); print PID "$pid"; close (PID); exit 0; } POSIX::setsid () || exit 1; # follow the leader open STDERR, '>&STDOUT'; Guaranteed to become the session leader, and completely dissociates from the terminal. - Mark To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-questions" in the body of the message