title: is there a way of knowing if a file descriptor opened for write has someone listening on the read side?
body: <p>i have fifo open in one side for read and in the other side for write, the read side close the fd he opened . is there a way of know if the reader closed this fd in the writer side ? 
  i want that the writer will have any notification about whether the reader is ready to read because if not my writer will get blocked on write .
  writer.c :</p>
  
  <pre><code>#include &lt;fcntl.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;string.h&gt;
  
  int main()
  {
      int fd;
       char * myfifo = "/tmp/fifo_pipe";
      /* create the FIFO (named pipe) */
      mkfifo(myfifo, 0666);
  
      /* write "Hi" to the FIFO */
      fd = open(myfifo, O_WRONLY);    
  
      write(fd, "Hey", sizeof("Hey"));
  
      /*here is there a posibilty of know that the read side hase close hi's side of the pipe before write? */
  
      write(fd, "test\n", strlen("test\n"));
  
  
      close(fd);
  
      /* remove the FIFO */
      unlink(myfifo);
  
      return 0;
  }
  </code></pre>
  
  <p>reader.c :</p>
  
  <pre><code>#include &lt;fcntl.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;unistd.h&gt;
  
  #define MAX_BUF 1024
  
  int main()
  {
      int fd;
      char * myfifo = "/tmp/fifo_pipe";
      char buf[MAX_BUF];
  
      /* open, read, and display the message from the FIFO */
      fd = open(myfifo, O_RDONLY);
      read(fd, buf, MAX_BUF);
      printf("Received: %s\n", buf);
      close(fd);
  
      return 0;
  }
  </code></pre>