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

I just observed that if I use FH instead of my $fh as the first arg to open(), it works

Replies are listed 'Best First'.
Re^4: how to kill background process when script exit?
by Corion (Patriarch) on Feb 21, 2011 at 15:56 UTC

    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.