How to stop fgets reading from FIFO file
<p>I have two processes, first reading from stdin and writing to FIFO file, second is waiting for message from FIFO file.</p>

<p>I am using this program structure:</p>

<pre><code>while(run)
{
  fgets(string, sizeof(string), fp);
}
</code></pre>

<p>and when the sentinel (run) change to 0 to stop process, it didn't really stop because it stuck in <code>fgets()</code> function.
How can I solve it?</p>

<p>I want program to waits for the message when sentinel change to 0 then immediately stop the program.</p>