in reply to Re^8: how to kill background process when script exit?
in thread how to kill background process when script exit?
The following code behaves just like it should (and like I said) for me:
corion@aliens:~/tmp$ cat test.pl #!perl -w use strict; my $pid = open my $fh, 'sleep 1000 |' or die "Couldn't spawn: $! / $?"; print "Spawned child as $pid"; print "Doing own work $_\n" for 1..10; print "Killing child $pid"; kill 9 => $pid; print "done\n";
corion@aliens:~/tmp$ perl -w test.pl Spawned child as 26868Doing own work 1 Doing own work 2 Doing own work 3 Doing own work 4 Doing own work 5 Doing own work 6 Doing own work 7 Doing own work 8 Doing own work 9 Doing own work 10 Killing child 26868done
I'm not sure what you're doing differently.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: how to kill background process when script exit?
by Allasso (Monk) on Feb 20, 2011 at 19:02 UTC | |
|
Re^10: how to kill background process when script exit?
by Allasso (Monk) on Feb 20, 2011 at 23:36 UTC | |
|
Re^10: how to kill background process when script exit?
by Allasso (Monk) on Feb 20, 2011 at 18:58 UTC |