From 8dd81503df9a78ea78c7de0613eb5b91d91f35d2 Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Wed, 5 Nov 1997 23:33:58 +0000 Subject: [PATCH] 1) Fix longstanding bug: trap 'echo xxx' 1 2 3 15 read x is not interrupted by ^C (due to restartable read syscall) and must be interrupted per POSIX Worse case: read -t 5 x hangs forever after ^C pressed (supposed to timeout after 5 secs) Fixed by adding siginterrupt(signo, 1) after catch handler installed 2) Do not reinstall sighandler immediately after it is called, BSD do it for us --- bin/sh/trap.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/sh/trap.c b/bin/sh/trap.c index f227f0274700..809f1b60d9d5 100644 --- a/bin/sh/trap.c +++ b/bin/sh/trap.c @@ -33,7 +33,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: trap.c,v 1.8 1997/02/22 13:58:46 peter Exp $ */ #ifndef lint @@ -212,6 +212,7 @@ setsignal(signo) int action; sig_t sigact = SIG_DFL; char *t; + long sig; if ((t = trap[signo]) == NULL) action = S_DFL; @@ -280,7 +281,12 @@ setsignal(signo) case S_IGN: sigact = SIG_IGN; break; } *t = action; - return (long)signal(signo, sigact); + sig = (long)signal(signo, sigact); +#ifdef BSD + if (sig != -1 && action == S_CATCH) + sig = siginterrupt(signo, 1); +#endif + return sig; } @@ -339,8 +345,9 @@ void onsig(signo) int signo; { - +#ifndef BSD signal(signo, onsig); +#endif if (signo == SIGINT && trap[SIGINT] == NULL) { onint(); return;