title: Check an exec is writing to stdin or not in C
body: <p>For my program, i have a main file and a helper file, connected by pipes. The main file writes to the helper file through stdin and the helper writes to the main by stdout. the helper file is a child process to the main by a fork, then runs an exec.
  How can i have the helper method check if the pipe is closed, when it is reading from what is stdin?
  At the moment i'm using the code below, but it just sits in a infinite loop as EOF for stdin is ctrl-D, which will never happen as the main function is only sending strings of data (mostly integers).</p>
  
  <pre><code>while (1) {
                  read(0, buffer, 20 );
                  sscanf(buffer, "%d" , &amp;info.numAgents);
                  if (feof(stdin)) {
                          fprintf(stdout, "Handler communication breakdown.\n");
                          exit(4);
                  }
  
  
          }
  </code></pre>