Close file after a kill command
<p>I have an infinite loop in my program where it will write in a file defined as stdout until I kill it. Therefore, the file will never be closed and won't contain what was wrote.</p>

<p>Is there a way to close the file after a kill command ? </p>

<p>I could use signals, like </p>

<pre><code>signal(SIGTERM, close(filename));
</code></pre>

<p>but how would I handle all the kill signals ?</p>