in reply to How can I kill subprocesses when the main script dies?
If you keep the PIDs for your kids in %children, that'll do it. For example, the following script dies, but still prints the ending notice:END { kill 'INT' => keys %children; }
#!/usr/bin/perl -w use strict; BEGIN { print "This is at the start\n"; } die; print "This is in the middle.\n"; exit; print "This should never print.\n"; END { print "This is in the end.\n"; }
|
|---|