From owner-cvs-bin Sun Feb 1 09:13:07 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA02629 for cvs-bin-outgoing; Sun, 1 Feb 1998 09:13:07 -0800 (PST) (envelope-from owner-cvs-bin) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA02443; Sun, 1 Feb 1998 09:11:17 -0800 (PST) (envelope-from steve@FreeBSD.org) From: Steve Price Received: (from steve@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id JAA27617; Sun, 1 Feb 1998 09:11:08 -0800 (PST) Date: Sun, 1 Feb 1998 09:11:08 -0800 (PST) Message-Id: <199802011711.JAA27617@freefall.freebsd.org> To: cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-usrsbin@FreeBSD.ORG Subject: cvs commit: src/bin/csh file.c src/usr.sbin/sendmail/src recipient.c Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk steve 1998/02/01 09:11:08 PST Modified files: bin/csh file.c usr.sbin/sendmail/src recipient.c Log: setpwent now has a void return type, so remove the now bogus cast. Revision Changes Path 1.8 +3 -3 src/bin/csh/file.c 1.9 +1 -1 src/usr.sbin/sendmail/src/recipient.c From owner-cvs-bin Sun Feb 1 21:20:03 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id VAA04963 for cvs-bin-outgoing; Sun, 1 Feb 1998 21:20:03 -0800 (PST) (envelope-from owner-cvs-bin) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id VAA04697; Sun, 1 Feb 1998 21:16:57 -0800 (PST) (envelope-from dyson@FreeBSD.org) From: John Dyson Received: (from dyson@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id VAA02462; Sun, 1 Feb 1998 21:16:44 -0800 (PST) Date: Sun, 1 Feb 1998 21:16:44 -0800 (PST) Message-Id: <199802020516.VAA02462@freefall.freebsd.org> To: cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG Subject: cvs commit: src/bin/ps print.c Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk dyson 1998/02/01 21:16:44 PST Modified files: bin/ps print.c Log: Display VSZ much more accurately now. Revision Changes Path 1.24 +2 -3 src/bin/ps/print.c From owner-cvs-bin Fri Feb 6 10:15:42 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA24258 for cvs-bin-outgoing; Fri, 6 Feb 1998 10:15:42 -0800 (PST) (envelope-from owner-cvs-bin) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA24065; Fri, 6 Feb 1998 10:15:17 -0800 (PST) (envelope-from cracauer@FreeBSD.org) From: Martin Cracauer Received: (from cracauer@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id KAA18305; Fri, 6 Feb 1998 10:14:27 -0800 (PST) Date: Fri, 6 Feb 1998 10:14:27 -0800 (PST) Message-Id: <199802061814.KAA18305@freefall.freebsd.org> To: cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG Subject: cvs commit: src/bin/sh jobs.c Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk cracauer 1998/02/06 10:14:27 PST Modified files: bin/sh jobs.c Log: Fix handling of SIGINT/SIGQUIT for foreground subprocesses. Most urgent need is when you run sh around a program that intentionally uses SIGQUIT/SIGINT for asynchronous events, i.e. $EDITOR started from system(2), like many mailers do. This fixes PR bin/1206 and possibly bin/4241. The solution committed has been tested for a large number of possible cases (see recent discussion on cvs-committers). I completed a make world, made sure 'make world' is interruptable and used the changed /bin/sh as a login shell all day, including job control and using SIGQUIT-catching programs (to write this message :-). PR: bin/1206 Reviewed by: discussion on cvs-commiters Revision Changes Path 1.18 +17 -1 src/bin/sh/jobs.c From owner-cvs-bin Fri Feb 6 11:30:36 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA08699 for cvs-bin-outgoing; Fri, 6 Feb 1998 11:30:36 -0800 (PST) (envelope-from owner-cvs-bin) 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 LAA08642; Fri, 6 Feb 1998 11:30:13 -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 GAA07506; Sat, 7 Feb 1998 06:28:44 +1100 Date: Sat, 7 Feb 1998 06:28:44 +1100 From: Bruce Evans Message-Id: <199802061928.GAA07506@godzilla.zeta.org.au> To: cracauer@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Subject: Re: cvs commit: src/bin/sh jobs.c Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > Modified files: > bin/sh jobs.c > Log: > Fix handling of SIGINT/SIGQUIT for foreground subprocesses. Most > urgent need is when you run sh around a program that intentionally > uses SIGQUIT/SIGINT for asynchronous events, i.e. $EDITOR started from > system(2), like many mailers do. This fixes PR bin/1206 and possibly > bin/4241. > > The solution committed has been tested for a large number of possible > cases (see recent discussion on cvs-committers). I completed a make > world, made sure 'make world' is interruptable and used the changed > /bin/sh as a login shell all day, including job control and using > SIGQUIT-catching programs (to write this message :-). > > PR: bin/1206 > Reviewed by: discussion on cvs-commiters I thought we were still discussing it. I didn't like it before, and like it less now. The committed version has the following bugs: 1) SIGINT/SIGQUIT are not restored after fork failure. 2) SIGINT/SIGQUIT are always reset to SIG_DFL in the child. This is wrong if these signals are ignored on entry to the shell. 3) SIGTERM apparently needs to be handled like SIGINT/SIGQUIT. bash seems to handle it like that. I'm testing the following fix: diff -c2 trap.c~ trap.c *** trap.c~ Tue Nov 11 18:15:35 1997 --- trap.c Fri Feb 6 23:51:08 1998 *************** *** 223,228 **** switch (signo) { case SIGINT: ! if (iflag) ! action = S_CATCH; break; case SIGQUIT: --- 223,227 ---- switch (signo) { case SIGINT: ! action = S_CATCH; break; case SIGQUIT: *************** *** 239,242 **** --- 238,243 ---- if (iflag) action = S_IGN; + else + action = S_CATCH; break; #if JOBS *************** *** 402,406 **** int on; { ! static int is_interactive = 0; if (on == is_interactive) --- 403,407 ---- int on; { ! static int is_interactive = -1; if (on == is_interactive) Bruce From owner-cvs-bin Fri Feb 6 15:02:05 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA17945 for cvs-bin-outgoing; Fri, 6 Feb 1998 15:02:05 -0800 (PST) (envelope-from owner-cvs-bin) Received: from lsd.relcom.eu.net (ache@lsd.relcom.eu.net [193.124.23.23]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA17707; Fri, 6 Feb 1998 15:00:48 -0800 (PST) (envelope-from ache@lsd.relcom.eu.net) Received: (from ache@localhost) by lsd.relcom.eu.net (8.8.8/8.8.8) id CAA24897; Sat, 7 Feb 1998 02:00:36 +0300 (MSK) (envelope-from ache) Message-ID: <19980207020036.28713@nagual.pp.ru> Date: Sat, 7 Feb 1998 02:00:36 +0300 From: =?koi8-r?B?4c7E0sXKIP7F0s7P1w==?= To: Bruce Evans , cracauer@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Subject: Re: cvs commit: src/bin/sh jobs.c Mail-Followup-To: Bruce Evans , cracauer@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-committers@FreeBSD.ORG References: <199802061928.GAA07506@godzilla.zeta.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1i In-Reply-To: <199802061928.GAA07506@godzilla.zeta.org.au>; from bde@zeta.org.au on Sat, Feb 07, 1998 at 06:28:44AM +1100 Organization: Biomechanoid Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Sat, Feb 07, 1998 at 06:28:44AM +1100, Bruce Evans wrote: > > Modified files: > > bin/sh jobs.c > > Log: > > Fix handling of SIGINT/SIGQUIT for foreground subprocesses. Most > > urgent need is when you run sh around a program that intentionally > > uses SIGQUIT/SIGINT for asynchronous events, i.e. $EDITOR started from > > system(2), like many mailers do. This fixes PR bin/1206 and possibly > > bin/4241. > > > > The solution committed has been tested for a large number of possible > > cases (see recent discussion on cvs-committers). I completed a make > > world, made sure 'make world' is interruptable and used the changed > > /bin/sh as a login shell all day, including job control and using > > SIGQUIT-catching programs (to write this message :-). > > > > PR: bin/1206 > > Reviewed by: discussion on cvs-commiters > > I thought we were still discussing it. I didn't like it before, and > like it less now. The committed version has the following bugs: > > 1) SIGINT/SIGQUIT are not restored after fork failure. > 2) SIGINT/SIGQUIT are always reset to SIG_DFL in the child. This is > wrong if these signals are ignored on entry to the shell. I agree with Bruce. I can confirm that discussion still not finished: my complaint was equal to 1) in his list and I see no answer from you too. Please back out your change and resolve all issues first. Personaly I like Bruce's variant more. -- Andrey A. Chernov http://www.nagual.pp.ru/~ache/ From owner-cvs-bin Fri Feb 6 15:51:38 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA24194 for cvs-bin-outgoing; Fri, 6 Feb 1998 15:51:38 -0800 (PST) (envelope-from owner-cvs-bin) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA24151; Fri, 6 Feb 1998 15:51:33 -0800 (PST) (envelope-from cracauer@FreeBSD.org) From: Martin Cracauer Received: (from cracauer@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id PAA19445; Fri, 6 Feb 1998 15:50:40 -0800 (PST) Date: Fri, 6 Feb 1998 15:50:40 -0800 (PST) Message-Id: <199802062350.PAA19445@freefall.freebsd.org> To: cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG Subject: cvs commit: src/bin/sh jobs.c Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk cracauer 1998/02/06 15:50:40 PST Modified files: bin/sh jobs.c Log: Back out my previous attempt to fix SIGINT/SIGTERM behaviour Revision Changes Path 1.19 +0 -16 src/bin/sh/jobs.c From owner-cvs-bin Fri Feb 6 17:20:23 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id RAA08041 for cvs-bin-outgoing; Fri, 6 Feb 1998 17:20:23 -0800 (PST) (envelope-from owner-cvs-bin) Received: from cons.org (knight.cons.org [194.233.237.86]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id RAA08006; Fri, 6 Feb 1998 17:20:07 -0800 (PST) (envelope-from cracauer@cons.org) Received: (from cracauer@localhost) by cons.org (8.8.5/8.7.3) id CAA19537; Sat, 7 Feb 1998 02:21:30 +0100 (CET) Message-ID: <19980207022127.48731@cons.org> Date: Sat, 7 Feb 1998 02:21:27 +0100 From: Martin Cracauer To: Bruce Evans Cc: cracauer@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Subject: Re: cvs commit: src/bin/sh jobs.c References: <199802061928.GAA07506@godzilla.zeta.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.81 In-Reply-To: <199802061928.GAA07506@godzilla.zeta.org.au>; from Bruce Evans on Sat, Feb 07, 1998 at 06:28:44AM +1100 Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > I thought we were still discussing it. I didn't like it before, and > like it less now. The committed version has the following bugs: I backed it out. > 1) SIGINT/SIGQUIT are not restored after fork failure. That just needs if (oldsigs_valid) { signal(SIGQUIT,oldsigquit); signal(SIGINT,oldsigint); oldsigs_valid = 0; } in the (pid == -1) clause. > 2) SIGINT/SIGQUIT are always reset to SIG_DFL in the child. This is > wrong if these signals are ignored on entry to the shell. Under what circumstances will a child be entered with ignored signals? One use I can think of is spawning subshells in a shellscript. If signals are always resetted to default, subshells will be exited at once and the whole shellscript will be terminated on one. This is also what bash and pdksh do. So below for an example. I don't think ignoring signals is useful for any fork() that is to be followed by exec(). Everything else is a subshell and therefore part of the script which should exit as a whole on the first SIGINT. > 3) SIGTERM apparently needs to be handled like SIGINT/SIGQUIT. bash > seems to handle it like that. SIGTERM is a different matter. What I'm trying to fix are characters that can be generated from a terminal keyboard and will therefore be used for asynchronous actions by applications. > I'm testing the following fix: [diff ommited] Two test cases where your and my solutions differ: 1) #!/usr/src/bin/sh.work/sh emacs -nw while `true` ; do foo=1 ; done After emacs exits, your version exits the loop only on SIGINT. SIGQUIT and SIGTERM are ignored. My solution exits on all three signals. 2) #!/usr/src/bin/sh.work/sh ( ( emacs -nw while `true` ; do foo=1 ; done ) while `true` ; do foo=1 ; done ) while `true` ; do foo=1 ; done After exiting emacs, my version drops out of all subshells and terminate the whole script on one SIGINT, which I think is the right thing to do. Your version needs three to exit the script. As I said, bash and pdksh need only one as well. And your version ignores both SIGQUIT and SIGTERM, which probably isn't intended. I also managed to bring you version into endless sh in malloc(): warning: recursive call. several by sending mixed signals, but I can't remember the exact sequence for now, sorry. I know that my solution is ugly, but it so far it does what I think is the right thing in all cases. 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 From owner-cvs-bin Sat Feb 7 03:16:55 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id DAA21704 for cvs-bin-outgoing; Sat, 7 Feb 1998 03:16:55 -0800 (PST) (envelope-from owner-cvs-bin) 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 DAA21416; Sat, 7 Feb 1998 03:15:32 -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 WAA04970; Sat, 7 Feb 1998 22:10:44 +1100 Date: Sat, 7 Feb 1998 22:10:44 +1100 From: Bruce Evans Message-Id: <199802071110.WAA04970@godzilla.zeta.org.au> To: bde@zeta.org.au, cracauer@cons.org Subject: Re: cvs commit: src/bin/sh jobs.c Cc: cracauer@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >> 1) SIGINT/SIGQUIT are not restored after fork failure. > >That just needs > if (oldsigs_valid) { > signal(SIGQUIT,oldsigquit); > signal(SIGINT,oldsigint); > oldsigs_valid = 0; > } >in the (pid == -1) clause. It also needs spaces after commas and uncorrupted tabs. >> 2) SIGINT/SIGQUIT are always reset to SIG_DFL in the child. This is >> wrong if these signals are ignored on entry to the shell. > >Under what circumstances will a child be entered with ignored signals? Whenever the shell was started with ignored signals, and when the shell is told to ignore signals using `trap'. >One use I can think of is spawning subshells in a shellscript. If >signals are always resetted to default, subshells will be exited at >once and the whole shellscript will be terminated on one. This is also >what bash and pdksh do. So below for an example. I think the main use is for running process trees with SIGHUP ignored. This is not so useful for SIGINT/SIGQUIT/SIGTERM, but still right. It would be surprising for subprocesses to reset to SIG_DFL just because they are created by a shell. I don't believe that bash or pdksh get this wrong. >Two test cases where your and my solutions differ: > >1) > #!/usr/src/bin/sh.work/sh > emacs -nw > while `true` ; do foo=1 ; done > >After emacs exits, your version exits the loop only on SIGINT. SIGQUIT >and SIGTERM are ignored. My solution exits on all three signals. My version doesn't work because onsig() only forwards SIGINT to onint(). Other caught signals are effectively ignored unless they have a trap handler. The INTOFF/INTON stuff only controls SIGINT. Some bugs are easier to reproduce if the emacs command is removed and `true` is replaced by ":" so that more time is spent setting foo: 1a) #!obj/sh while : ; do foo=1 ; done Killing this with ^C often yields: sh in malloc(): warning: recursive call. This is an old bug. onintr() calls outstr("\n") to clean up the output after the tty driver echos ^C. outstr() calls malloc(). It is not OK to call malloc() from a signal handler. phkmalloc detects the problem and prints the warning if malloc() was active when the signal occurred (this happens almost half the time for (1a) on one of my systems). It returns 0 immediately. outstr() actually uses ckmalloc(). ckmalloc() calls error() when malloc() returns 0. error() calls outstr() which calls malloc()... 1b) #!obj/sh trap '' 2 while : ; do foo=1 ; done This seems to work incorrectly with both sh and bash-1. ^C correctly doesn't kill it, but neither does ^\ or SIGTERM. ^Z and SIGHUP work. >2) >#!/usr/src/bin/sh.work/sh >( > ( > emacs -nw > while `true` ; do foo=1 ; done > ) > while `true` ; do foo=1 ; done >) >while `true` ; do foo=1 ; done > >After exiting emacs, my version drops out of all subshells and >terminate the whole script on one SIGINT, which I think is the right >thing to do. Your version needs three to exit the script. As I said, >bash and pdksh need only one as well. I agree that terminating on one SIGINT is right. The different behaviour seems to have something to do with the handling of exit statuses from the children. bash doesn't exit either for: 2a) #!/usr/local/bin/bash while : ; do catch2 ; echo $?; done where catch2 exits with a non-signal status when it catches SIGINT. It takes several SIGINTs to kill this - apparently SIGINTs are effectively ignored if they occur while the child is alive. >And your version ignores both SIGQUIT and SIGTERM, which probably >isn't intended. It wasn't intended, but gives the same behaviour as bash. My version actually catches them and then ignores them (unless they are trapped). Bruce From owner-cvs-bin Sat Feb 7 07:18:01 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA17631 for cvs-bin-outgoing; Sat, 7 Feb 1998 07:18:01 -0800 (PST) (envelope-from owner-cvs-bin) Received: from cons.org (knight.cons.org [194.233.237.86]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA17587; Sat, 7 Feb 1998 07:17:54 -0800 (PST) (envelope-from cracauer@cons.org) Received: (from cracauer@localhost) by cons.org (8.8.5/8.7.3) id QAA22711; Sat, 7 Feb 1998 16:19:21 +0100 (CET) Message-ID: <19980207161921.47866@cons.org> Date: Sat, 7 Feb 1998 16:19:21 +0100 From: Martin Cracauer To: Bruce Evans Cc: cracauer@cons.org, cracauer@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Subject: Re: cvs commit: src/bin/sh jobs.c References: <199802071110.WAA04970@godzilla.zeta.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.81 In-Reply-To: <199802071110.WAA04970@godzilla.zeta.org.au>; from Bruce Evans on Sat, Feb 07, 1998 at 10:10:44PM +1100 Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk OK, I'm convinced it isn't as easy as I thought. We're in bad need for clarification what the desired behaviour is. I think the best thing to do is to suspend the issue and I'll write a little testsuite first. We can then make our minds up whether what my testsuite expects is right and then test different versions against it. Again, if someone has some test cases to add, let me know. What does POSIX say about the issue? 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 From owner-cvs-bin Sat Feb 7 08:00:24 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA22681 for cvs-bin-outgoing; Sat, 7 Feb 1998 08:00:24 -0800 (PST) (envelope-from owner-cvs-bin) 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 IAA22646; Sat, 7 Feb 1998 08:00:14 -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 CAA12906; Sun, 8 Feb 1998 02:56:19 +1100 Date: Sun, 8 Feb 1998 02:56:19 +1100 From: Bruce Evans Message-Id: <199802071556.CAA12906@godzilla.zeta.org.au> To: bde@zeta.org.au, cracauer@cons.org Subject: Re: cvs commit: src/bin/sh jobs.c Cc: cracauer@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >OK, I'm convinced it isn't as easy as I thought. We're in bad need for >clarification what the desired behaviour is. It's becoming messier in my version too. The triple ^C's were necessary because the subshells exited with a status of 128 + SIGINT and weren't killed by a signal. sh and (apparently) bash have special handling for the case where a subshell is killed by SIGINT. They send themself a SIGINT in this case. This should kill them if SIGINT wasn't ignored initially and isn't trapped. This was broken in my version because the SIGINT was caught. This version calls setsignal() just before the kill to get the correct handling. It frobs `rootshell' to avoid getting the normal handling. I think the complications handled by setsignal() must be handled somewhere in your version too. Here's another difference in behaviour: --- #!/bin/sh cat pwd --- If `cat' but not the shell is killed by SIGINT, then sh kills itself, but bash doesn't. sh should probably only kill itself if (intpending). Bruce diff -c2 error.c~ error.c *** error.c~ Tue Apr 29 04:24:04 1997 --- error.c Sun Feb 8 01:15:44 1998 *************** *** 107,111 **** sigemptyset(&sigset); sigprocmask(SIG_SETMASK, &sigset, NULL); ! out2str("\n"); if (rootshell && iflag) exraise(EXINT); --- 107,111 ---- sigemptyset(&sigset); sigprocmask(SIG_SETMASK, &sigset, NULL); ! write(STDERR_FILENO, "\n", 1); if (rootshell && iflag) exraise(EXINT); diff -c2 jobs.c~ jobs.c *** jobs.c~ Sun Feb 8 01:25:10 1998 --- jobs.c Sun Feb 8 01:44:43 1998 *************** *** 636,640 **** } #endif ! if (wasroot && iflag) { setsignal(SIGINT); setsignal(SIGQUIT); --- 636,640 ---- } #endif ! if (wasroot) { setsignal(SIGINT); setsignal(SIGQUIT); *************** *** 695,698 **** --- 695,699 ---- int status; int st; + int wasroot; INTOFF; *************** *** 727,732 **** freejob(jp); CLEAR_PENDING_INT; ! if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT) kill(getpid(), SIGINT); INTON; return st; --- 728,739 ---- freejob(jp); CLEAR_PENDING_INT; ! if (WIFSIGNALED(status) && WTERMSIG(status) == SIGINT) { ! wasroot = rootshell; ! rootshell = 0; /* XXX */ ! setsignal(SIGINT); ! rootshell = wasroot; kill(getpid(), SIGINT); + setsignal(SIGINT); + } INTON; return st; diff -c2 trap.c~ trap.c *** trap.c~ Tue Nov 11 18:15:35 1997 --- trap.c Sat Feb 7 22:05:34 1998 *************** *** 223,228 **** switch (signo) { case SIGINT: ! if (iflag) ! action = S_CATCH; break; case SIGQUIT: --- 223,227 ---- switch (signo) { case SIGINT: ! action = S_CATCH; break; case SIGQUIT: *************** *** 237,242 **** /* FALLTHROUGH */ case SIGTERM: ! if (iflag) ! action = S_IGN; break; #if JOBS --- 236,240 ---- /* FALLTHROUGH */ case SIGTERM: ! action = S_IGN; break; #if JOBS *************** *** 402,406 **** int on; { ! static int is_interactive = 0; if (on == is_interactive) --- 400,404 ---- int on; { ! static int is_interactive = -1; if (on == is_interactive) From owner-cvs-bin Sat Feb 7 08:40:21 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA00991 for cvs-bin-outgoing; Sat, 7 Feb 1998 08:40:21 -0800 (PST) (envelope-from owner-cvs-bin) 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 IAA00954; Sat, 7 Feb 1998 08:40:11 -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 DAA14095; Sun, 8 Feb 1998 03:39:15 +1100 Date: Sun, 8 Feb 1998 03:39:15 +1100 From: Bruce Evans Message-Id: <199802071639.DAA14095@godzilla.zeta.org.au> To: bde@zeta.org.au, cracauer@cons.org Subject: Re: cvs commit: src/bin/sh jobs.c Cc: cracauer@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk This example seems to handled correctly by at least my hacked sh, but not by bash: #!/bin/sh set -x trap '' 2 while : ; do cat; echo -n $?; done bash.1 says more clearly than sh.1 that the null trap causes the signal to be ignored by invoked commands, but only sh behaves as documented. Bruce From owner-cvs-bin Sat Feb 7 08:50:39 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA01738 for cvs-bin-outgoing; Sat, 7 Feb 1998 08:50:39 -0800 (PST) (envelope-from owner-cvs-bin) 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 IAA01703; Sat, 7 Feb 1998 08:50:30 -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 DAA14279; Sun, 8 Feb 1998 03:45:59 +1100 Date: Sun, 8 Feb 1998 03:45:59 +1100 From: Bruce Evans Message-Id: <199802071645.DAA14279@godzilla.zeta.org.au> To: bde@zeta.org.au, cracauer@cons.org Subject: Re: cvs commit: src/bin/sh jobs.c Cc: cracauer@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk I wrote: >#!/bin/sh >set -x >trap '' 2 >while : ; do cat; echo -n $?; done > >bash.1 says more clearly than sh.1 that the null trap causes the signal >to be ignored by invoked commands, but only sh behaves as documented. Version 2 of bash behaves as documented. Bruce From owner-cvs-bin Sat Feb 7 09:53:48 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA08287 for cvs-bin-outgoing; Sat, 7 Feb 1998 09:53:48 -0800 (PST) (envelope-from owner-cvs-bin) Received: from cons.org (knight.cons.org [194.233.237.86]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA08260; Sat, 7 Feb 1998 09:53:41 -0800 (PST) (envelope-from cracauer@cons.org) Received: (from cracauer@localhost) by cons.org (8.8.5/8.7.3) id SAA22967; Sat, 7 Feb 1998 18:41:36 +0100 (CET) Message-ID: <19980207184135.12964@cons.org> Date: Sat, 7 Feb 1998 18:41:35 +0100 From: Martin Cracauer To: Bruce Evans Cc: cracauer@cons.org, cracauer@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Subject: Re: cvs commit: src/bin/sh jobs.c References: <199802071645.DAA14279@godzilla.zeta.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.81 In-Reply-To: <199802071645.DAA14279@godzilla.zeta.org.au>; from Bruce Evans on Sun, Feb 08, 1998 at 03:45:59AM +1100 Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Another difference with subshells. While your versions runs the first test fine (shell doesn't exit while emacs runs, but is interruptable afterwards), it fails on the second, the script is terminated when SIGINT is delivered to emacs. The problem here is that it doesn't always ignore before it forks a foreground process. #!./testshell ./emacs -nw while : ; do foo=1 ; done #!./testshell ( ( ./emacs -nw while : ; do foo=1 ; done ) while : ; do foo=1 ; done ) while : ; do foo=1 ; done -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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 From owner-cvs-bin Sat Feb 7 11:20:25 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA17303 for cvs-bin-outgoing; Sat, 7 Feb 1998 11:20:25 -0800 (PST) (envelope-from owner-cvs-bin) 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 LAA17235; Sat, 7 Feb 1998 11:20: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 GAA18082; Sun, 8 Feb 1998 06:18:44 +1100 Date: Sun, 8 Feb 1998 06:18:44 +1100 From: Bruce Evans Message-Id: <199802071918.GAA18082@godzilla.zeta.org.au> To: bde@zeta.org.au, cracauer@cons.org Subject: Re: cvs commit: src/bin/sh jobs.c Cc: cracauer@FreeBSD.ORG, cvs-all@FreeBSD.ORG, cvs-bin@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Sender: owner-cvs-bin@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Another difference with subshells. While your versions runs the first >test fine (shell doesn't exit while emacs runs, but is interruptable >afterwards), it fails on the second, the script is terminated when >SIGINT is delivered to emacs. The problem here is that it doesn't >always ignore before it forks a foreground process. > >#!./testshell >./emacs -nw >while : ; do foo=1 ; done > > >#!./testshell >( > ( > ./emacs -nw > while : ; do foo=1 ; done > ) > while : ; do foo=1 ; done >) >while : ; do foo=1 ; done My version doesn't change the behaviour of subshells. sh does extra work to reset the signals in the subshell. This was easy to "fix" by removing the test for rootshell in setsignal(), except that breaks my hack for resetting SIGINT to get the correct exit status. Here is another bug: #!/bin/sh set -x trap 'echo t' 2 while : ; do (echo 1; cat); echo $?; done The subshell is optimized away, although this isn't valid because the trap should be reset in the subshell. Bruce