[Pdx-pm] to fork or thread...
rootbeer at redcat.com
Sun Sep 21 13:15:58 CDT 2003
On Sun, 21 Sep 2003, Chris Dawson wrote:
> I have been experimenting with fork, but I don't know the proper way to
> kill the child process.
Many processes terminate on their own, when their input runs out or
whatever. If your program can be made to do this, that's almost certainly
the best way to go. But if it is going to run until you stop it, keep the
pid (returned from fork), and use that to kill the child. Probably like
this, if you want it simple:
kill 'HUP', $pid;
If there's some reason that your process might survive the HUP signal,
there are others, like 'INT'. But don't let anyone tell you to use signal
9 before you've tried something simpler.
> I have tried writing a script which upon the stop() method, runs a
> 'killall program_name' but this appears to leave a bunch of zombie
> processes, which is not optimal.
The FAQ talks about this; try 'perldoc -q zombies'.
> I don't think the zombies are an issue and are not consuming resources,
> but I think there must be a limit to the number of child processes
> associated with an application, correct?
Don't leave dead children lying around. This advice is also useful when
you're not programming.
Does that take care of what you're looking for? Cheers!
More information about the Pdx-pm-list