diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 1997-11-05 23:33:58 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 1997-11-05 23:33:58 +0000 |
commit | 8dd81503df9a78ea78c7de0613eb5b91d91f35d2 (patch) | |
tree | b10c190d823f9f5c5e988510e55f025f202c1ac2 /bin/sh | |
parent | b113690ced8b2224712ac560709567f7c01a30d9 (diff) | |
download | src-8dd81503df9a78ea78c7de0613eb5b91d91f35d2.tar.gz src-8dd81503df9a78ea78c7de0613eb5b91d91f35d2.zip |
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
Notes
Notes:
svn path=/head/; revision=30969
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/trap.c | 13 |
1 files 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; |