UNIX commands in C

Chris Torek torek at elf.ee.lbl.gov
Tue Apr 30 06:15:41 AEST 1991


(Having just written a new man page for popen, I cannot resist following
up, even though I should be off getting some food....)

In article <174 at shasta.Stanford.EDU> shap at shasta.Stanford.EDU (shap) writes:
>popen(3) also has an interesting "feature." ... Et Voilla! instant deadlock.

This cannot happen directly because of popen().  The reason is
trivially simple: popen opens either for reading or for writing, never
both.  Thus popen() is unable to create a loop, and deadlock occurs
only in the presence of a pipe loop.  (The situation described in `...'
is the simplest case, where A writes to B and then reads back from B:
A->B->A.  The problem also occurs in longer loops such as A->B->C->D->A.)

>For those of you who don't believe this happens, talk to some people
>who have had to port various window managers.

These generally use bidirectional entities such as ptys and must
therefore provide their own synchronization mechanisms.
-- 
In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427)
Berkeley, CA		Domain:	torek at ee.lbl.gov



More information about the Comp.unix.questions mailing list