Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: How to get the PID of an invoked process

by IraTarball (Monk)
on Jul 21, 2001 at 01:43 UTC ( [id://98554]=note: print w/replies, xml ) Need Help??


in reply to How to get the PID of an invoked process

If you need the PID you might want to look at fork and exec. fork will return the childs pid, you can then have the child exec the system call. As I understand it, this is what system() does at it's core. Check out perldoc -f fork and perldoc -f exec for examples and details. I wrote the following that seems to work, no error checking though.
use strict; use warnings; $SIG{CHLD} = '"IGNORE"'; my $child = fork(); if ($child) { print "I'm the parent, I think I'll wait for the child $child...\n +"; waitpid($child, 0); } else { exec ("ls"); }

Good Luck,
Ira.

"So... What do all these little arrows mean?"
~unknown

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://98554]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-25 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found