Page 1 of 1

Regarding Process Ids

Posted: Sun Oct 23, 2005 6:40 am
by karthick
Hi all ,
I need to write an utility prgm in perl which should work like this

perl 3(level) PID prgmname.pl(perl program)

If the level and PID are given then the prgm might display the child and grandchild pid's upto the given level.


the output should look like

PID
---------------------------------------------------------------
| |
child1PID child2 PID
-------------------------------------- ----------------------
| | | | |
grandchild
PID ........... child 2's child
PID
.
.
.
the Id needs to be fetched upto the given levels


any idea please notify me

thanks&regards,
karthick

Posted: Sun Oct 23, 2005 2:52 pm
by Pills
And this has what to do with IRC?

Moved to off-topic.

Posted: Sun Oct 23, 2005 9:27 pm
by Nico
Since your program will mess with process ids, your code will most probably be platform dependant.

If your target platform is Win32, then you should have a look to Win32::Process::Info and its Subprocesses method.

If it's Linux, *BSD or *nix, you might find Proc::ProcessTable and Proc::ProcessTable::Process interesting. These module allow you to retrieve a list of the current processes and to get details about any of them (like the ppid). I think you can manage to do what you want by looping in the list, checking if the parent pid matches.