Date: Thu, 5 Feb 1998 21:38:33 +0100 From: Martin Cracauer <cracauer@cons.org> To: cvs-commiters@FreeBSD.ORG Cc: cracauer@cons.org Subject: Re: Please review fix for /bin/sh SIGQUIT/SIGINT problem Message-ID: <19980205213833.25257@cons.org> In-Reply-To: <19980205204320.31887@cons.org>; from Martin Cracauer on Thu, Feb 05, 1998 at 08:43:20PM %2B0100 References: <19980205202824.51394@cons.org> <19980205204320.31887@cons.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This diff fixes interactive shells in the case of background jobs. Any
more special case?
diff -r -c sh.original/jobs.c sh/jobs.c
*** sh.original/jobs.c Mon Mar 10 10:53:43 1997
--- sh/jobs.c Thu Feb 5 21:28:56 1998
***************
*** 86,91 ****
--- 86,94 ----
int initialpgrp; /* pgrp of shell on invocation */
short curjob; /* current job */
#endif
+ sig_t oldsigint;
+ sig_t oldsigquit;
+ int oldsigs_valid = 0;
STATIC void restartjob __P((struct job *));
STATIC void freejob __P((struct job *));
***************
*** 553,558 ****
--- 556,566 ----
TRACE(("forkshell(%%%d, 0x%lx, %d) called\n", jp - jobtab, (long)n,
mode));
INTOFF;
+ if (mode == FORK_FG) {
+ oldsigquit = signal(SIGQUIT,SIG_IGN);
+ oldsigint = signal(SIGINT,SIG_IGN);
+ oldsigs_valid = 1;
+ }
pid = fork();
if (pid == -1) {
TRACE(("Fork failed, errno=%d\n", errno));
***************
*** 565,570 ****
--- 573,580 ----
int i;
TRACE(("Child shell %d\n", getpid()));
+ signal(SIGQUIT,SIG_DFL);
+ signal(SIGINT,SIG_DFL);
wasroot = rootshell;
rootshell = 0;
for (i = njobs, p = jobtab ; --i >= 0 ; p++)
***************
*** 674,679 ****
--- 684,695 ----
while (jp->state == 0) {
dowait(1, jp);
}
+ if (oldsigs_valid) {
+ signal(SIGQUIT,oldsigquit);
+ signal(SIGINT,oldsigint);
+ oldsigs_valid = 0;
+ }
+
#if JOBS
if (jp->jobctl) {
if (ioctl(2, TIOCSPGRP, (char *)&mypgrp) < 0)
--
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@cons.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980205213833.25257>
