CTRL-C is not usable on macOS with sbcl

17 views
Skip to first unread message

oldk1331

unread,
Jan 21, 2019, 6:43:59 AM1/21/19
to fricas...@googlegroups.com
CTRL-C can not interrupt a loop on macOS with sbcl.

The reason is that macOS doesn't have MSG_NOSIGNAL, so we
install a SIGPIPE handler in src/lib/sockio-c.c.

But it seems that SIGPIPE is used by SIGINT somehow in sbcl:
https://github.com/sbcl/sbcl/blob/master/src/code/target-signal.lisp#L201

Is using SO_NOSIGPIPE a possible solution?  Or are there
better solutions?

oldk1331

unread,
Jan 22, 2019, 8:33:11 AM1/22/19
to fricas...@googlegroups.com
I think we can ignore SIGPIPE when "send" syscall can return EPIPE:

diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c
index 17cc1056..683fd7c4 100644
--- a/src/lib/sockio-c.c
+++ b/src/lib/sockio-c.c
@@ -882,9 +882,11 @@ open_server(char *server_name)

init_socks();
#ifndef HAVE_MSG_NOSIGNAL
+#ifndef HAVE_EPIPE
#ifdef SIGPIPE
bsdSignal(SIGPIPE, sigpipe_handler,RestartSystemCalls);
#endif
+#endif
#endif
if (make_server_name(name, server_name) == -1)
return -2;

Waldek Hebisch

unread,
Jan 23, 2019, 12:07:47 PM1/23/19
to fricas...@googlegroups.com
oldk1331 wrote:
>
> I think we can ignore SIGPIPE when "send" syscall can return EPIPE:
>

No. We can ignore SIGPIPE when "send" syscall _will_ return EPIPE
and this happens when we say it to do so. On Linux we
use MSG_NOSIGNAL for this. On Mac you found SO_NOSIGPIPE...
So we need appropriate configure magic to find out if
one MSG_NOSIGNAL or SO_NOSIGPIPE is available and conditionals
in code to act on this.

--
Waldek Hebisch

oldk1331

unread,
Jan 23, 2019, 11:26:50 PM1/23/19
to fricas...@googlegroups.com
You are right. I've create a patch that utilizes SO_NOSIGPIPE.
This works on macOS and should work on FreeBSD (I didn't test).
avoid-SIGPIPE-on-macsOS.patch

Waldek Hebisch

unread,
Jan 25, 2019, 10:18:46 AM1/25/19
to fricas...@googlegroups.com
oldk1331 wrote:
>
> You are right. I've create a patch that utilizes SO_NOSIGPIPE.
> This works on macOS and should work on FreeBSD (I didn't test).
>

OK, please commit.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages