Fifo Flushing Error
<p>I am trying this code,</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;pthread.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;fcntl.h&gt;
#include&lt;stdio.h&gt;
#include&lt;stdlib.h&gt;
#include&lt;string.h&gt;
#include&lt;unistd.h&gt;
#include&lt;signal.h&gt;

int fileFD = 0;
pthread_t Thread_application;
pthread_t Read_Thread;
void * Waiting_Thread(void * arg)
{
    while(1) {
        printf("Created Thread\n");
        sleep(1);
    }
}


void * Readtread(void *arg)
{
    char buf[1902] = {0};
    int ret = 0;
    while(1) {
        ret = read(fileFD, buf, 120);
        printf("Read Bytes\n");
    }


}
void main()
{
    int i = 0;

    mkfifo("Desktop/Trail_Programs/ClientFIFO", 0666);
    fileFD = open("Desktop/Trail_Programs/ClientFIFO", O_RDWR);
    pthread_create(&amp;Thread_application, NULL, Waiting_Thread, NULL);
    pthread_create(&amp;Read_Thread, NULL, Readtread, NULL);
    sleep(10);

    close(fileFD);
    pthread_kill(Thread_application, 0);
    pthread_kill(Read_Thread, 0);


    system("dd if=Desktop/Trail_Programs/ClientFIFO iflag=nonblock of=/dev/null");

    for(i = 0; i &lt; 10; i++) {

        printf("Main Thread \n");
        fflush(stdout);
    }
}
</code></pre>

<blockquote>
  <p>Output:    Created Thread</p>
  
  <p>Created Thread</p>
  
  <p>Created Thread</p>
  
  <p>Created Thread</p>
  
  <p>Created Thread</p>
  
  <p>Created Thread</p>
  
  <p>Created Thread</p>
  
  <p>Created Thread</p>
  
  <p>Created Thread</p>
  
  <p>Created Thread</p>
  
  <p>Created Thread</p>
  
  <p>dd: error reading
  ‘Desktop/Trail_Programs/ClientFIFO’: Resource
  temporarily unavailable</p>
  
  <p>0+0 records in</p>
  
  <p>0+0 records out</p>
  
  <p>0 bytes (0 B) copied, 0.000314463 s, 0.0 kB/s</p>
  
  <p>Main Thread </p>
  
  <p>Main Thread </p>
  
  <p>Main Thread </p>
  
  <p>Main Thread </p>
  
  <p>Main Thread </p>
  
  <p>Main Thread </p>
  
  <p>Main Thread </p>
  
  <p>Main Thread </p>
  
  <p>Main Thread </p>
  
  <p>Main Thread</p>
</blockquote>

<p>I suppose read is blocking while i am trying to flush the fifo into /dev/null. In my use case opening file with O_NONBLOCK flag and using select to monitor fd, keeps my other processes lagging. please help me with some suggestions</p>

<p>Thanks and Regards,</p>

<p>Ap</p>