Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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
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.

    CountZero

    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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://998192]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-07-31 05:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (245 votes), past polls