[K42-discussion] Another problem with asynchrony
Bryan S Rosenburg
rosnbrg at us.ibm.com
Wed Oct 12 06:07:28 EST 2005
When you write to a pipe whose other end has been closed, the write is
supposed to fail with an errno of EPIPE, and in addition you are supposed
to receive a SIGPIPE.
In Linux, unless you ignore or handle the signal, it will always kill you
before you get back from the write. (I make this assertion on only a
little evidence.)
In K42, the pipe server can generate the signal before returning EPIPE,
but there's no good way to ensure that the signal is acted on before the
write returns. In practice, I've found that the client sometimes sees the
write return and sometimes it doesn't.
As far as I can tell, Posix says nothing more than:
The write() and pwrite() functions shall fail if:
. . . .
[EPIPE]
An attempt is made to write to a pipe or FIFO that is not open for reading
by any process, or that only has one end open. A SIGPIPE signal shall also
be sent to the thread.
which by itself doesn't seem to imply any degree of synchronicity. But
there may be constraints on when a signal "sent" to a thread because of
the thread's own action must be delivered.
In any case, I think Linux programs will be surprised if they survive to
see an EPIPE returned from write, whether or not they should be.
I'm not proposing to do anything about this problem right now, but I
thought I'd put it out for discussion.
- Bryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ozlabs.org/pipermail/k42-discussion/attachments/20051011/7d381843/attachment.htm
More information about the K42-discussion
mailing list