[ Usenet FAQs | Web FAQs | Documents | RFC Index ]
    Search the FAQ Archives

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page

Top Document: Unix - Frequently Asked Questions (4/7) [Frequent posting]
Previous Document: How can an executing program determine its own pathname?
Next Document: How do I sleep() in a C program for less than one second?


How do I use popen() to open a process for reading AND writing?



4.5)  How do I use popen() to open a process for reading AND writing?

      The problem with trying to pipe both input and output to an
      arbitrary slave process is that deadlock can occur, if both
      processes are waiting for not-yet-generated input at the same
      time.  Deadlock can be avoided only by having BOTH sides follow a
      strict deadlock-free protocol, but since that requires
      cooperation from the processes it is inappropriate for a
      popen()-like library function.

      The 'expect' distribution includes a library of functions that a
      C programmer can call directly.  One of the functions does the
      equivalent of a popen for both reading and writing.  It uses ptys
      rather than pipes, and has no deadlock problem.  It's portable to
      both BSD and SV.  See question 3.9 for more about 'expect'.



Top Document: Unix - Frequently Asked Questions (4/7) [Frequent posting]
Previous Document: How can an executing program determine its own pathname?
Next Document: How do I sleep() in a C program for less than one second?

Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page


[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
tmatimar@isgtec.com (Ted Timar)

Last Update October 22 2009 @ 05:35 AM

Some parts © 2009 Advameg, Inc.