Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Jun 1996 09:16:54 +1000 (EST)
From:      John Birrell <cimaxp1!jb@werple.net.au>
To:        zeta.org.au!bde@melb.werple.net.au (Bruce Evans)
Cc:        hackers@FreeBSD.org, jb@cimlogic.com.au
Subject:   Re: Nonblocking writes to pipes hang
Message-ID:  <199606152317.JAA28030@melb.werple.net.au>
In-Reply-To: <199606151304.XAA12653@godzilla.zeta.org.au> from "Bruce Evans" at Jun 15, 96 11:04:02 pm

next in thread | previous in thread | raw e-mail | index | archive | help
[ Bruce, thanks for taking the trouble to give a detailed reply. 8-). ]

> Writes of >= 8192 bytes are just broken.  pipe_direct_write() is
> called in this case and it never checks the PIPE_NBIO flag.

Is this easy to fix, or should we code to ensure we only do non-blocking
writes < 8192? I assume the problem exists in both 2.1R and 2.2-current.

> My pipe throughput test program shows another interesting pipe bug.
> When WORK_AROUND_FREEBSD_BUGS is not defined, the reader sometimes hangs
> waiting for EOF even though the writer has closed the pipe (or has
> exited).

Ugh. We rely on this _working_. The most common case where we use pipes
is to re-direct output from one program to another. Our build process,
for instance, execs cc, ar, ld etc with stdout and stderr piped back to
the build program (which we use instead of make) so that we can save
error and warning messages in the build version history. The only way
that our build program knows when there is nothing more to read from
the pipe when it is closed by the writer.

> This is caused by last-close semantics being broken as
> designed.  The fileops close function only gets called when both the
> reader and the writer have closed the pipe.  Thus if the reader is
> waiting for input and the writer dies, the pipe code doesn't get
> notified and the reader continues waiting for input that can never
> arrive.  For named pipes, input can arrive, but reads still block for
> too long.  POSIX.1 requires that reads unblock when the pipe is closed
> by all processes that had it open for writing.  FreeBSD's bidirectional
> pipes seem to fix the problem for the wrong reason - it is impossible
> to close a read/write descriptor while you're reading from it, so it
> is impossible for all writers to close a pipe that you're reading from.

I don't know how we can work around this problem. Are there any issues
that would prevent this problem being fixed? To us it is a "job-stopper".

> 
> Bruce


Regards,

-- 
John Birrell                                CIMlogic Pty Ltd
jb@cimlogic.com.au                          119 Cecil Street
Ph  +61  3 9690 6900                        South Melbourne Vic 3205
Fax +61  3 9690 6650                        Australia
Mob +61 18  353  137



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199606152317.JAA28030>