From owner-freebsd-current Tue Feb 10 11:36:42 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA28834 for current-outgoing; Tue, 10 Feb 1998 11:36:42 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from cons.org (knight.cons.org [194.233.237.86]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA28815 for ; Tue, 10 Feb 1998 11:36:36 -0800 (PST) (envelope-from cracauer@cons.org) Received: (from cracauer@localhost) by cons.org (8.8.5/8.7.3) id UAA00178; Tue, 10 Feb 1998 20:38:08 +0100 (CET) Message-ID: <19980210203807.25569@cons.org> Date: Tue, 10 Feb 1998 20:38:07 +0100 From: Martin Cracauer To: Bruce Evans Cc: freebsd-current@FreeBSD.ORG Subject: Re: cvs commit: src/bin/sh jobs.c References: <199802101742.EAA16027@godzilla.zeta.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.81 In-Reply-To: <199802101742.EAA16027@godzilla.zeta.org.au>; from Bruce Evans on Wed, Feb 11, 1998 at 04:42:20AM +1100 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In <199802101742.EAA16027@godzilla.zeta.org.au>, Bruce Evans wrote: [edited my patch as you requested] > I checked an old draft of POSIX.2. The main points about signal handling > seem to be: > > 1. For async commands, SIGINT and SIGQUIT from the keyboard shall be > prevented from interrupting the command. Otherwise, signal handling > shall be inherited from the shell's parent. > > Notes. This seems to require SIGINT and SIGQUIT not from the keyboard > to not be handled specially. (How can the shell tell whether stdin is > connected to _the_ keyboard? ;-). This doesn't specify handling of > signals by the shell itself. I'll try to get ahold of a newer POSIX document, maybe they became more specific. > 2. If the shell is waiting for a forground command, and a signal with a > trap handler is received, then "the trap shall not be executed until > after the foreground command has been completed". > > Notes. Presumably, trapped signals are supposed to be received and not > just ignored while waiting for a command. Your change breaks this in > most cases, since the shell ignores SIGINT and SIGQUIT while waiting. I agree that this is probably intended, but I'm not sure this is the right thing to do. Suppose I have $EDITOR set to a script like this: #!/bin/sh emacs -nw "$@" somecleanup or an application calls system("emacs -nw ; somecleanup-in-shell") The cleanup will not be run when the user uses SIGINT/SIGQUIT in emacs, but it will be run when the user exits emacs without using these signals. In my opinion, if the user uses an application that uses SIGINT and SIGQUIT for its own purposes (that means, using these signals is part of normal program usage like any other keystroke is), then the surrounding shell should not take any action based on the signals. No matter if it is done synchonously or after the childs exits. The script above should run the cleanup in any case. Also, I would like to avoid waking up the shell everytime a signal arrives. /bin/csh behaves as you describe, BTW. I added a test for this to my suite. > The SIGINT case still works, accidentally, when the foreground command > is killed by a SIGINT. Then the shell forwards the signal to itself > after it restores its signal catcher. This can probably be fixed > by replacing the signal(..., SIG_IGN)'s by a sigprocmask(SIG_BLOCK, > ...), etc. Signals will be delayed until they are unblocked after the > command completes, but this is precisely what is wanted. Hm, unless I'm convinced otherwise, this isn't what I want. It's fine in the case that the child is killed by (did not catch) the signal, though. As you said, my version accidentally does exactly what I want for both bases. I'll answer the other points later, got to drive home now. Martin -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Martin Cracauer http://www.cons.org/cracauer cracauer@wavehh.hanse.de (batched, preferred for large mails) Tel.: (daytime) +4940 41478712 Fax.: (daytime) +4940 41478715 Tel.: (private) +4940 5221829 Fax.: (private) +4940 5228536 Paper: (private) Waldstrasse 200, 22846 Norderstedt, Germany To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe current" in the body of the message