Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

44. Pipes and FIFOs > Pipes and stdio Buffering

Pipes and stdio Buffering

Since the file stream pointer returned by a call to popen() doesn’t refer to a terminal, the stdio library applies block buffering to the file stream (Buffering in the stdio Library). This means that when we call popen() with a mode of w, then, by default, output is sent to the child process at the other end of the pipe only when the stdio buffer is filled or we close the pipe with pclose(). In many cases, this presents no problem. If, however, we need to ensure that the child process receives data on the pipe immediately, then we can either use periodic calls to fflush() or disable stdio buffering using the call setbuf(fp, NULL). This technique can also be used if we create a pipe using the pipe() system call and then use fdopen() to obtain a stdio stream corresponding to the write end of the pipe.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint