From b1a46a64f829789406b9192367e98c3e10a73a4e Mon Sep 17 00:00:00 2001 From: cracauer Date: Tue, 8 Sep 1998 13:16:52 +0000 Subject: If traps are set, they are now executed even when a signal-blocking foreground child is running. Formerly, traps were exceuted after the next child exit. The enables the user to put a breaking wrapper around a blocking application: (trap 'echo trap ; exit 1' 2; ./pestyblocker; echo -n) The "echo -n" after the child call is needed to prevent sh from optimizing the trap-executing shell away. I'm working on this. --- bin/sh/jobs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'bin/sh/jobs.c') diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c index 202fa67..c08758e 100644 --- a/bin/sh/jobs.c +++ b/bin/sh/jobs.c @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; #endif static const char rcsid[] = - "$Id: jobs.c,v 1.21 1998/08/24 10:20:36 cracauer Exp $"; + "$Id: jobs.c,v 1.22 1998/08/25 09:33:34 cracauer Exp $"; #endif /* not lint */ #include @@ -88,6 +88,7 @@ int initialpgrp; /* pgrp of shell on invocation */ int curjob; /* current job */ #endif int in_waitcmd = 0; /* are we in waitcmd()? */ +int in_dowait = 0; /* are we in dowait()? */ volatile sig_atomic_t breakwaitcmd = 0; /* should wait be terminated? */ #if JOBS @@ -712,9 +713,9 @@ waitforjob(jp) INTOFF; TRACE(("waitforjob(%%%d) called\n", jp - jobtab + 1)); - while (jp->state == 0) { - dowait(1, jp); - } + while (jp->state == 0) + if (dowait(1, jp) == -1) + dotrap(); #if JOBS if (jp->jobctl) { #ifdef OLD_TTY_DRIVER @@ -771,11 +772,13 @@ dowait(block, job) int core; int sig; + in_dowait++; TRACE(("dowait(%d) called\n", block)); do { pid = waitproc(block, &status); TRACE(("wait returns %d, status=%d\n", pid, status)); } while (pid == -1 && errno == EINTR && breakwaitcmd == 0); + in_dowait--; if (breakwaitcmd != 0) { breakwaitcmd = 0; return -1; -- cgit v1.1