Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

get list of processes triggered from parent script

by doubledecker (Scribe)
on Oct 10, 2012 at 10:32 UTC ( #998192=perlquestion: print w/replies, xml ) Need Help??
doubledecker has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

I'm invoking a shell script from Perl script using Proc::Background module. shell script will invoke 10 parallel processes. I have PID of the parent process which gets completed after invoking all the parallel processes. How to get process id's of all the child processes that are triggered by parent process. any ideas are appreciated.

  • Comment on get list of processes triggered from parent script

Replies are listed 'Best First'.
Re: get list of processes triggered from parent script
by zentara (Archbishop) on Oct 10, 2012 at 10:45 UTC
    #!/usr/bin/perl -w use strict; use Proc::ProcessTable; # ignore the child $SIG{CHLD} = 'IGNORE'; # create 5 child processes for demo purpose. arrange them so they stay # long enough so we can find them later for(1..5){ sleep(10) and exit if(fork == 0); } # list all process running in your machine and find all # child process for my $p (@{new Proc::ProcessTable->table}){ print $p->pid," child of $$\n" if($p->ppid == $$); }

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: get list of processes triggered from parent script
by CountZero (Bishop) on Oct 10, 2012 at 12:46 UTC
    The objects created by Proc::Background have a pid method which return the background process' pid.


    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://998192]
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2018-03-18 08:59 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (229 votes). Check out past polls.