in reply to Re: how to kill background process when script exit?
in thread how to kill background process when script exit?

Most likely because the second snippet does an implicit

close $fh;

after the end of your program code and just before it starts to run the END block.

Replies are listed 'Best First'.
Re^3: how to kill background process when script exit?
by Allasso (Monk) on Feb 21, 2011 at 15:47 UTC
    I just observed that if I use FH instead of my $fh as the first arg to open(), it works

      This likely is because the globals are only cleaned up on global destruction, that is, they live until after the last END block has run. As you kill the child before that, this allows things to work as expected.