title: invalid handle exception when debugging
body: <p>I have following message while I am in debug mode in Visual studio 2010 <code>Unhandled exception at 0x76c5f9e2 in test.exe: 0xC0000008: An invalid handle was specified.</code>When I run this in regular mode I don't get this error.
  The debugger stops in close.c at this line</p>
  
  <pre><code>CloseHandle( (HANDLE)_get_osfhandle(fh) ) )
  </code></pre>
  
  <p>Does anyone have any sugestion how such error could be avoided?</p>