Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Proc-ProcessTable alternative

by anshumangoyal (Scribe)
on Oct 13, 2012 at 14:18 UTC ( #998850=perlquestion: print w/ replies, xml ) Need Help??
anshumangoyal has asked for the wisdom of the Perl Monks concerning the following question:

I am using active perl (v5.12.4) in windows. There is a program which forks a number of processes as child processes. at the end of program i want to get all PID's of these processes and kill them to complete the program. Is there any windows tool/command or a package which can help me get info about all the processes which have been forked? Heard about Proc-ProcessTable but this only works in unix and not in windows. Even i am unable to install it using 'ppm install Proc-ProcessTable'

Comment on Proc-ProcessTable alternative
Re: Proc-ProcessTable alternative
by Anonymous Monk on Oct 13, 2012 at 14:28 UTC
Re: Proc-ProcessTable alternative
by pokki (Scribe) on Oct 13, 2012 at 23:45 UTC

    Uh.

    You're forking with fork(), I assume? So you're probably using the standard forking idiom

    if (my $pid = fork()) { # do stuff in the parent } else { # do stuff in the child }

    or a variant thereof.

    The return value of fork() is, according to the perldoc, undef if the fork failed, 0 if the fork succeeded and you're in the child process, or the child's PID if the fork succeeded and you're in the parent process. So the parent process gets the forked process' PID as fork()'s return value. You can collect these every time you fork and manage your child processes however you want.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://998850]
Approved by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2014-08-20 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (114 votes), past polls