Running stdin/out through a pipe to a child process

David Elliott dce at mips.UUCP
Tue Jan 20 01:43:50 AEST 1987


With all of this discussion about pipes, I thought I'd bring up the
subject of a (4.[23]BSD) bug involving closing two pipes in succession:

1. A pipe is opened, written to, closed, and the child process is waited on.
After termination, this is done again. All goes as expected.

2. Two pipes are opened and written to. Next, both pipes are closed. Finally,
each child process is waited for. All goes as expected, except that I
find it odd that the second child is found by wait() first. This really
isn't the problem anyway.

3. Two pipes are opened and written two. Afterwards, each pipe is closed and
the child process waited for (that is, pipe 1 is closed and child 1 is
waited for and then pipe 2 is closed and child 2 is waited for). In this
case, the first wait() blocks, and the first child never terminates except
when the parent does.

I have reduced these 3 cases as much as possible by inlining the code for
popen() and pclose() and getting rid of the stdio code used by them (stdio
exists only to print error messages in the programs). The result is a set
of programs that directly call the system calls involved.

If anyone would like to work on this problem, I can send out copies of
these programs (the whole deal is about 8K of source, but I didn't want
to clutter up the net).

-- 
			David Elliott

UUCP: 	{decvax,ucbvax,ihnp4}!decwrl!mips!dce, DDD:  	408-720-1700



More information about the Comp.unix.questions mailing list