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.
In reply to Re^9: how to kill background process when script exit?
by Corion
in thread how to kill background process when script exit?
by Allasso
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |