From owner-freebsd-current Wed Feb 11 09:10:18 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA04294 for current-outgoing; Wed, 11 Feb 1998 09:10:18 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA04280 for ; Wed, 11 Feb 1998 09:10:16 -0800 (PST) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id EAA04905; Thu, 12 Feb 1998 04:05:41 +1100 Date: Thu, 12 Feb 1998 04:05:41 +1100 From: Bruce Evans Message-Id: <199802111705.EAA04905@godzilla.zeta.org.au> To: bde@zeta.org.au, cracauer@cons.org Subject: Re: cvs commit: src/bin/sh jobs.c Cc: freebsd-current@FreeBSD.ORG Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >> >> (c) #!/bin/sh >> >> (while :; do catchint; done) >> >> >> >> Now there is a subshell. It must be killed by SIGINT. (?) >> > >> >For me (our sh and bash), the whole script (outer shell, inner shell, >> >catchint) is terminated on SIGINT. It's the way it should be, IMHO. >> >> Actually, it doesn't for your version of sh, or bash. At least for >> your version of sh, the subshell waits for catchint, and then doesn't >> exit because catchint exits with a normal status. > >There must be some misunderstanding here. > >If catchint is a program with SIGINT => SIGN_DFL, all versions of sh >(original, your, mine, bash) exit this script (test10.sh from >testsuite) immedeatly: It's not. It's a program that catches SIGINT and exits normally (i.e., with a non-signal status) in its SIGINT handler. >#!./testshell >echo 'You should be able to end the script with one SIGINT' >(while :; do wc /kernel > /dev/null ; done) wc doesn't catch SIGINT. >The first SIGINT kills wc, the inner shell and the outer shell. Not quite. The first SIGINT kills wc, but is ignored by both shells (probably incorrectly by at least the inner shell). Then the inner shell notices that wc was killed with a SIGINT and relays this SIGINT to itself by killing itself with a SIGINT. This kills it completely because it is no longer ignoring SIGINT. Then the outer shell notices that the inner shell was killed by a SIGINT and relays the SIGINT to itself, etc. Relaying is not done for signals other than SIGINT, so test10.sh can't be killed by SIGQUIT with your version of sh. >If you mean catchint to be a program that directs SIGINT to its own >routine and not exit on it, then you're right, this loop isn't >breakable by SIGINT if the shell behaves the way I think is right. Yes, if the shell behaves the way I think is wrong. >If an application catches SIGINT for its own purposes (i.e. emacs), >then - in my opinion - the surrounding shellscript should not behave >different when a) the catchint program ends without using SIGINT and >b) the catchint program ends and has used SIGINT while it was running. If a program wants to use SIGINT, then it should avoid sending it to the entire process group. This prevents it from using SIGINTs generated by the tty. >This is the only way to ensure that an application we can assure that >system(2) does what the application writer expects if he/she calls it >with $EDITOR. Hmm. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe current" in the body of the message