From 760264169e554e3e2ae8312f8f192d1ad95c7854 Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 22 Nov 2009 18:23:30 +0000 Subject: Fix various things about SIGINT handling: * exception handlers are now run with interrupts disabled, which avoids many race conditions * fix some cases where SIGINT only aborts one command and continues the script, in particular if a SIGINT causes an EINTR error which trumped the interrupt. Example: sh -c 'echo < /some/fifo; echo This should not be printed' The fifo should not have writers. When pressing ctrl+c to abort the open, the shell used to continue with the next command. Example: sh -c '/bin/echo < /some/fifo; echo This should not be printed' Similar. Note, however, that this particular case did not and does not work in interactive mode with job control enabled. --- bin/sh/redir.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'bin/sh/redir.c') diff --git a/bin/sh/redir.c b/bin/sh/redir.c index 695e150..08878f6 100644 --- a/bin/sh/redir.c +++ b/bin/sh/redir.c @@ -166,8 +166,11 @@ openredirect(union node *redir, char memory[10]) /* * We suppress interrupts so that we won't leave open file - * descriptors around. This may not be such a good idea because - * an open of a device or a fifo can block indefinitely. + * descriptors around. Because the signal handler remains + * installed and we do not use system call restart, interrupts + * will still abort blocking opens such as fifos (they will fail + * with EINTR). There is, however, a race condition if an interrupt + * arrives after INTOFF and before open blocks. */ INTOFF; memory[fd] = 0; -- cgit v1.1