title: perl hangs on exit (after closing a filehandle)
body: <p>I've got a function that does (in short):</p>
  
  <pre><code>my $file = IO::File-&gt;new("| some_command &gt;&gt; /dev/null 2&gt;&amp;1") 
      or die "cannot open some_command for writing: $!\n";
  ...
  undef $file;
  </code></pre>
  
  <p>Right now I'm not even writing anything to <code>$file</code>. Currently there are no other operations on <code>$file</code> at all. When I run the program, it doesn't exit properly. I see that handle is closed, but my program is still waiting for the process to close. Captured with <code>strace</code>:</p>
  
  <pre><code>close(6)                                = 0
  rt_sigaction(SIGHUP, {SIG_IGN}, {SIG_DFL}, 8) = 0
  rt_sigaction(SIGINT, {SIG_IGN}, {SIG_DFL}, 8) = 0
  rt_sigaction(SIGQUIT, {SIG_IGN}, {SIG_DFL}, 8) = 0
  wait4(16861, ^C &lt;unfinished ...&gt;
  </code></pre>
  
  <p>I don't see this problem if I open the same process for reading.</p>
  
  <p>What do I have to do to make the program to exit?</p>
  
  <p>Edit: Suggestions so far were to use the Expect library or to finish the input stream via ctrl+d. But I do not want to interact with the program in any way at this point. I want it to finish exactly <em>now</em> without any more IO going on. Is that possible?</p>