bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: run.c translator


From: Niels Möller
Subject: Re: run.c translator
Date: 20 Mar 2002 22:42:04 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

Roland McGrath <roland@gnu.org> writes:

> Saying "bidirectional pipe" is descriptive too. :-) They're the same thing.
> As we discussed in great detail here at the time, `pipe' now creates a
> bidirectional pipe, i.e. it creates a socketpair and does not call
> shutdown.

You ought to set some flag somewhere so that you get the PIPE_BUF
behaviour for pipes, but *not* for socketpairs, right?

Problem is as follows: Say I want to write 200 bytes, and 200 <
PIPE_BUF. I use non-blocking i/o, and call select to wait until the fd
is writable. Lets assume that at this point, there's 100 bytes left in
the pipe buffers. Then write will fail: It won't do a partial write of
100 bytes, because it wants to guarantee that writes smaller than
PIPE_BUF are atomic.

This makes it painful to use pipes with non-blocking i/o (the easiest
work-around is to fall back to writing a single byte whenever select
says the fd is writable, but write fails). Or simply use socketpair
instead, as that doesn't have the PIPE_BUF behaviour; in the above
example write ought to return 100, and the next select call will wait
until there's more buffer space.

Regards,
/Niels



reply via email to

[Prev in Thread] Current Thread [Next in Thread]