in reply to wrong pid
My guess is that the PID you're getting back is the PID of the shell before it forks process_tar.pl. So yes, I think the ampersand is your problem.
If I don't use the ampersand, the parent script waits until the command has completed which defeats the purpose of forking it.
It looks as if you want to send input to the subprocess. Do you want to do that and then not have to wait for it to finish? I suggest you fork first, and run the command after.
my $child_pid = fork(); if ( $child_pid ) { # parent goes about its business } elsif ( defined $child_pid ) { # child my $pid = open(PID, "|$cmd") or die "Can't fork: $!"; # blah blah # this hangs until process_tar.pl finishes. close(PID) or die "Can't close: $!"; exit; } else { die "Can't fork: $!"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: wrong pid
by js1 (Monk) on Apr 23, 2007 at 14:04 UTC | |
by kyle (Abbot) on Apr 23, 2007 at 14:24 UTC |