BadFileDescriptor IOexception when operating on a file closed by a shutdown hook
<p>I am working at an application that traces the execution of a java application with a java agent instrumentation.</p>

<p>The agent writes data to a file and there is a shoutdownHook which closes it.</p>

<p>Unfortunately it seems that sometimes the hook closes the file too early (Is it possible?) and I get a BadFileDescriptor IOexception on an attempt to write to the output file.</p>

<p>Do you have any idea about how could I fix the problem?
I am using the latest version of Java available for Mac OS X.</p>
