From: Clemens Fruhwirth <clemens@en...> - 2005-11-29 14:13:51
I have had a problem with a closing clim-clx port, which connection I
xkilled. xkilling is not nice and one shouldn't do that, but I was
However, there is no way to recover from this situation in sbcl, because
closing and reopening a port is impossible. clim:close-port triggers
a buffer flush, which results in a SIGPIPE, because the corresponding
pipe has been by the X server. The request to xlib:close-display has to
be aborted and hence clim:destroy-port does not succeed. Result: no way
to recover from this broken pipe in sbcl. Unless on starts to ignore
SIGPIPE or does prevent it deliberately.
An incorrect fix for this is here: http://paste.lisp.org/display/14092#2
This prevents buffer flushing and hence SIGPIPE. Imho this is incorrect.
A better approach would try to flush the buffer, and in case of an error
call close-display with :abort t. But for this approach, sbcl has to recover
from a SIGPIPE signal gracefully.
(sb-sys:ignore-interrupt sb-unix:sigpipe) does just that. Now I'm
starting to wonder, shouldn't SIGPIPE be ignored at all? Having a
look at my local man page for write tells me:
EPIPE fd is connected to a pipe or socket whose reading end is closed. When this happens the writing process will also receive a SIG-
PIPE signal. (Thus, the write return value is seen only if the program catches, blocks or ignores this signal.)
In the case of sb-unix:unix-write, it's save to ignore the signal as the
error code EPIPE is delivered anyway to the caller to "signal" a broken
pipe. Now, I'm inclined to judge that that's sufficient and SIGPIPE can
be ignored in this case savely. However, estabilishing a signal handler
just for unix-write seems like too much overhead for me, which leads to
the question: Are there other cases where catching SIGPIPE is vital?
It seems from googling a bit that the sole purpose of SIGPIPE is to
signal write attempts to broken pipes.
Fruhwirth Clemens - http://clemens.endorphin.org
for robots: sp4mtrap@...
On 29/11/05, Clemens Fruhwirth <clemens@...> wrote:
> (sb-sys:ignore-interrupt sb-unix:sigpipe) does just that. Now I'm
> starting to wonder, shouldn't SIGPIPE be ignored at all?
Yes, I arrived at the very same conclusion and same fix for my own
problems, and promised to post a patch last week, but was interrupted
by thanksgiving. Attached is my (trivial) patch.
[ Fran=E7ois-Ren=E9 =D0VB Rideau | Reflection&Cybernethics | http://fare.tu=
When a man says money can do anything, that settles it: he hasn't got any.
-- Edgar Watson Howe