On Mon, Aug 24, 2009 at 6:37 PM, Jonathan Swartz<[email protected]> wrote:
> Yes, getting the pid from each process launch is not the problem - it's
> more of a wish that I could do this automagically somehow, instead of
> having to collect all the pids somewhere. But it seems as if I'll have
> to do that.
Is it feasible for what your doing to fork off, and do a setsid call
to create a new process group? If so, at the end of the testing, you
can just send a signal to your process group, to kill off the
forked-off processes. Saves having to keep track of all forked off
processes...
sample script (without error checking)
===
#!/usr/bin/perl
use strict;
use warnings;
use POSIX qw( setsid );
if ( fork ) {
exit; # parent just exits
}
my $sid = setsid;
# do work here
kill -2, $sid; # negative signal to send to process group
===
Mark.