From owner-freebsd-current Tue Feb 10 06:11:34 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA01609 for current-outgoing; Tue, 10 Feb 1998 06:11:34 -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 GAA01586 for ; Tue, 10 Feb 1998 06:11:31 -0800 (PST) (envelope-from cracauer@cons.org) Received: (from cracauer@localhost) by cons.org (8.8.5/8.7.3) id PAA29471; Tue, 10 Feb 1998 15:12:59 +0100 (CET) Message-ID: <19980210151257.23319@cons.org> Date: Tue, 10 Feb 1998 15:12:57 +0100 From: Martin Cracauer To: Bruce Evans Cc: freebsd-current@FreeBSD.ORG, cracauer@cons.org Subject: Re: cvs commit: src/bin/sh jobs.c References: <199802071645.DAA14279@godzilla.zeta.org.au> <19980207195952.24691@cons.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.81 In-Reply-To: <19980207195952.24691@cons.org>; from Martin Cracauer on Sat, Feb 07, 1998 at 07:59:52PM +0100 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG The patch below makes sh pass all my tests. In addition to the last one, it also behaves right on: #!./testshell echo 'Test 2: You should not be able to exit cat with SIGINT.' echo ' But SIGQUIT should abort cat with coredump while' echo ' the shell should continue and call cat again.' echo ' SIGTERM should exit the whole script.' set -x trap '' 2 while : ; do cat ; echo -n $? ; done # End of script *** sh/jobs.c Tue Feb 10 10:42:47 1998 --- sh.cra/jobs.c Tue Feb 10 14:54:50 1998 *************** *** 86,89 **** --- 86,92 ---- int curjob; /* current job */ #endif + sig_t oldsigint; + sig_t oldsigquit; + int oldsigs_valid = 0; #if JOBS *************** *** 575,580 **** --- 578,593 ---- mode)); INTOFF; + if (mode == FORK_FG) { + oldsigquit = signal(SIGQUIT, SIG_IGN); + oldsigint = signal(SIGINT, SIG_IGN); + oldsigs_valid = 1; + } pid = fork(); if (pid == -1) { + if (oldsigs_valid) { + signal(SIGQUIT, oldsigquit); + signal(SIGINT, oldsigint); + oldsigs_valid = 0; + } TRACE(("Fork failed, errno=%d\n", errno)); INTON; *************** *** 587,590 **** --- 600,607 ---- TRACE(("Child shell %d\n", getpid())); + if (oldsigquit != SIG_IGN) + signal(SIGQUIT,SIG_DFL); + if (oldsigint != SIG_IGN) + signal(SIGINT,SIG_DFL); wasroot = rootshell; rootshell = 0; *************** *** 701,704 **** --- 718,727 ---- dowait(1, jp); } + if (oldsigs_valid) { + signal(SIGQUIT, oldsigquit); + signal(SIGINT, oldsigint); + oldsigs_valid = 0; + } + #if JOBS if (jp->jobctl) { To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe current" in the body of the message