Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

Unix - Frequently Asked Questions (4/7) [Frequent posting]
Section - How do I use popen() to open a process for reading AND writing?

( Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Business Photos and Profiles ]


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?
See reader questions & answers on this topic! - Help others by sharing your knowledge

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'.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




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 March 27 2014 @ 02:12 PM