summaryrefslogtreecommitdiffstats
path: root/bin/sh/redir.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2009-11-22 18:23:30 +0000
committerjilles <jilles@FreeBSD.org>2009-11-22 18:23:30 +0000
commit760264169e554e3e2ae8312f8f192d1ad95c7854 (patch)
treed42fd7d5720d96daa7589c733afd3cc29c10f330 /bin/sh/redir.c
parentba91da3aff4fb68aa0ec546f7eeb21855b267fc7 (diff)
downloadFreeBSD-src-760264169e554e3e2ae8312f8f192d1ad95c7854.zip
FreeBSD-src-760264169e554e3e2ae8312f8f192d1ad95c7854.tar.gz
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.
Diffstat (limited to 'bin/sh/redir.c')
-rw-r--r--bin/sh/redir.c7
1 files changed, 5 insertions, 2 deletions
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;
OpenPOWER on IntegriCloud