in reply to How to kill forked process
That said, you might be able to get away with the following (mostly pseudo-) code:
my $pid = fork(); if ($pid) { # in the parent wait for a keypress via your favourite method here if an abort occurs.. kill 15, $pid; # sigspec to taste exit; # parent is done # you'll probably want POSIX WNOHANG here, otherwise waitpid will bl +ock waitpid, $pid # child exited normally } elsif (defined $pid) { # in the child system("run_groovy_command"); exit; # tell daddy i'm done } else { die "Cannot fork: try spoon\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to kill forked process
by redss (Monk) on Feb 17, 2005 at 05:22 UTC | |
by zentara (Cardinal) on Feb 17, 2005 at 14:21 UTC |