in reply to Function to get a child pid
If your process isn't a child of your script, no. I think it depends heavily on the operating system running, too.
The easiest way I think of on Unix systems is something like this :
use strict; use warnings; sub get_childpids { my $father=shift; # linux style my @exec=`ps -o pid --ppid $father` or die "can't run ps! $! \n"; # SYS V style : use shell, needs cleansing # my @exec=`ps -eo ppid | grep $father` or die "can't run ps! $! \ +n"; # BSD style : use shell, needs cleansing # my $exec=`ps aux | grep $father` or die "can't run ps! $! \n"; shift @exec; chomp @exec; return @exec; }
|
|---|