Subject: bin/6213: /bin/sh mishandles trapped signals during "read"
To: None <gnats-bugs@gnats.netbsd.org>
From: Urban Boquist <boquist@cs.chalmers.se>
List: netbsd-bugs
Date: 09/29/1998 22:58:31
>Number:         6213
>Category:       bin
>Synopsis:       /bin/sh does not handle a trapped signal correctly
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 29 14:05:00 1998
>Last-Modified:
>Originator:     Urban Boquist
>Organization:
Dept. of CS, Chalmers, Sweden
>Release:        NetBSD-current
>Environment:
System: NetBSD dogbert.cs.chalmers.se 1.3H NetBSD 1.3H (DOGBERT) #0: Mon Sep 21 12:51:33 CEST 1998 root@dogbert.cs.chalmers.se:/usr/src/sys/arch/i386/compile/DOGBERT i386


>Description:
If you "trap" SIGTERM and then execute the sh builtin "read", the shell will
not react to SIGTERM until the "read" is done (you have to press RETURN).

>How-To-Repeat:
Run this shell script:
-------------------------------------
#!/bin/sh
trap foo 15
foo () { echo foo; exit 0; }
(sleep 5; kill $$; echo killed) &
echo waiting...
read bar
-------------------------------------

After 5 seconds it will print "killed", but not exit or print "foo" until
RETURN is pressed.

Btw, the same happens on a system built before the recent signal changes.

>Fix:
No idea, sorry.

>Audit-Trail:
>Unformatted: