[comp.unix.internals] Taking Control of stdin/stdout of a slave process

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (03/18/91)

In article <15500@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes:
> The fellow said FILE*s, but in any case there is a fundamental problem
> with the request that has no simple solution.  Namely, deadlock can
> easily occur in such a scenario.  Only with a carefully-designed
> communication protocol can one have confidence that deadlock will not
> occur.  That requires support on the slave end as well as the master,
> so the slave cannot be an arbitrary process.

A carefully designed protocol can ensure that deadlock will not occur,
but if you don't have control over the slave then the master can still
eliminate the chance of deadlock all by itself.

If, for example, the master forks into an output process and an input
process that does not synchronize with the output, then the situation
has as much chance of deadlock as the pipeline foo|slave|bar. The master
does not need to fork to eliminate the chance of deadlock: it can use
select() under BSD, or (with streams) poll() under System V, or any
number of thread libraries.

---Dan