PID of exec
am 25.10.2007 19:18:53 von hendedavGang,
I have looked all over google groups on how to find the pid of
the exec command when using the fork/exec. I will admit that I am not
overly familiar with the workings (I understand the idea though) of
these two commands. Here is what I am working with. I have a perl
script (see below) that calls a shell script that simply counts to
thirty while pausing for one second (basically is a script that does
nothing for 30 seconds so I can see if the PID is correct).
#!/usr/bin/perl
if (defined (my $pid = fork)) {
if ($pid)
{ #
this test runs if the fork was successful
local $SIG{CHLD} =
"IGNORE"; # eliminates the zombies
print "pid is $pid\n, parent pid is $$\n";
} else { # the
following line runs in the child
exec("./test.sh &");
print "child pid is: $$\n";
exit();
}
} else {
print "there was a problem executing the script\n";
}