Message ID | 20240329153905.154792-2-aclopte@gmail.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Herbert Xu |
Headers | show |
Series | [v3] Allow trap to un-ignore SIGINT/SIGQUIT in async subshells | expand |
On Fri, Mar 29, 2024 at 04:39:01PM +0100, Johannes Altmanninger wrote: > > diff --git a/src/trap.c b/src/trap.c > index cd84814..dbf81ea 100644 > --- a/src/trap.c > +++ b/src/trap.c > @@ -272,7 +272,7 @@ ignoresig(int signo) > signal(signo, SIG_IGN); > } > if (!vforked) > - sigmode[signo - 1] = S_HARD_IGN; > + sigmode[signo - 1] = S_IGN; This is buggy if sigmode is already S_HARD_IGN. You can fix this by moving the if statement inside the previous one. Please also add a comment stating that sigmode has already been initialised by setinteractive, as otherwise we may also lose a hard ignore. Thanks,
On Sun, Apr 07, 2024 at 07:18:52PM +0800, Herbert Xu wrote: > On Fri, Mar 29, 2024 at 04:39:01PM +0100, Johannes Altmanninger wrote: > > > > diff --git a/src/trap.c b/src/trap.c > > index cd84814..dbf81ea 100644 > > --- a/src/trap.c > > +++ b/src/trap.c > > @@ -272,7 +272,7 @@ ignoresig(int signo) > > signal(signo, SIG_IGN); > > } > > if (!vforked) > > - sigmode[signo - 1] = S_HARD_IGN; > > + sigmode[signo - 1] = S_IGN; > > This is buggy if sigmode is already S_HARD_IGN. You can fix > this by moving the if statement inside the previous one. > > Please also add a comment stating that sigmode has already been > initialised by setinteractive, as otherwise we may also lose a > hard ignore. I'm not really following the last part; maybe it's no longer relevant with the bug fix. Note that it works the same whether "set -i" or "trap - INT" is used, also in noninteractive shells like dash -c '( trap - INT; sleep inf ) & read _'
On Sat, May 18, 2024 at 10:43:12AM +0200, Johannes Altmanninger wrote: > > I'm not really following the last part; > maybe it's no longer relevant with the bug fix. > Note that it works the same whether "set -i" or "trap - INT" is used, > also in noninteractive shells like > > dash -c '( trap - INT; sleep inf ) & read _' All I meant was that if you call ignoresig before sigmode itself is initialised it will do the wrong thing if the signal was supposed to be a hard ignore. However, this can't happen because we only call ignoresig for SIGINT and SIGQUIT, and for those two signals, ignoresig is always called after setinteractive which will initialise the sigmode array to S_HARD_IGN if necessary. I'll add a comment when applying your patch. Thanks,
diff --git a/src/trap.c b/src/trap.c index cd84814..dbf81ea 100644 --- a/src/trap.c +++ b/src/trap.c @@ -272,7 +272,7 @@ ignoresig(int signo) signal(signo, SIG_IGN); } if (!vforked) - sigmode[signo - 1] = S_HARD_IGN; + sigmode[signo - 1] = S_IGN; }