| [reply] [Watch: Dir/Any] |
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 | [reply] [Watch: Dir/Any] [d/l] [select] |
$PROCESS_ID
$PID
$$
The process number of the Perl running this script. You should conside
+r this variable read-only, although it will be altered across fork()
+calls. (Mnemonic: same as shells.)
redmist
Silicon Cowboy | [reply] [Watch: Dir/Any] [d/l] |
Thanks to all! I'm happily fork'ing/exec'ing away now... | [reply] [Watch: Dir/Any] |