title: Using termios() to replace EOF?
body: <p>I have a psuedo terminal running on linux C, opened as shown:</p>
  
  <pre><code>else
  { 
       struct termios slave_orig_term_settings; // Saved terminal settings
       struct termios new_term_settings; // Current terminal settings
  
      // CHILD
      close(fdm);
  
      rc = tcgetattr(fds, &amp;slave_orig_term_settings);
  
      new_term_settings = slave_orig_term_settings;
  
      new_term_settings.c_cc[VEOF] = '|';
      new_term_settings.c_oflag &amp;= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ISIG | ICRNL);
  
      cfmakeraw (&amp;new_term_settings);
  
      tcsetattr (fds, TCSANOW, &amp;new_term_settings);
  
  }
  </code></pre>
  
  <p>When reading from the pipe, I can make a non blocking read() which will return after, for example, 5 seconds. The problem is that if I execute a command like "ls", which returns in several ms, it will wait the full 5 seconds before returning.</p>
  
  <p>I understand using a physical GUI terminal, and not a psuedo terminal like this, the user can press CTRL^D and have EOF sent at the end of each output. </p>
  
  <p>I want this effect, so my program can say "OK, I have received this certain byte, which means the terminal is done outputting, and I can now return this output back to the caller, and I know there is no more output to read". </p>
  
  <p>I understand this is done with termios() function (or it's wrapper stty), but I can't get it working. I want the terminal to send me the '|' char instead of ctrl^d (\x04) upon completion of output, but it isn't working.</p>
  
  <p>For clarity, upon completion of output (via read()), I want to receive the '|' byte. So if I send 'pwd' command, I get this output:</p>
  
  <pre><code> $ pwd
   /home/user/dir
   $|
  </code></pre>
  
  <p>Could someone please tell me how to edit this code to acheive that effect?</p>
  
  <p>Thanks for your help.</p>
  
  <p>EDIT - select() code</p>
  
  <pre><code>while ( (bytes = select(pipe + 1, &amp;fd_in, NULL, NULL, &amp;tv)) )
  {       
              if (FD_ISSET(pipe, &amp;fd_in))
              {
  
                  read (pipe...)
  </code></pre>
  
  <p>The behaviour of the above code is as I've described, to wait for the full value of tv, even if there is nothing on the pipe, before returning.</p>