On 2021-08-24 16:51:28 +0000, Thorsten Glaser wrote: > Vincent Lefevre dixit: > > >This is incorrect, because SIGINT should be ignored. > > > >This issue disappears when the subshell has several commands: > > > >$ mksh -c 'trap "" INT; trap; ( :; sleep 3; ); echo $?' > >trap -- '' INT > >^C0 > > Consider this: > > $ mksh -c 'trap "" INT; trap; ( :; exec sleep 3; ); echo $?' > trap -- '' INT > ^C130 > > The “one” command run in the subshell is exec’d so you’re hitting > the parent shell’s INT handler… I think. > > Feel free to have a look at the source and see if you come up with > what exactly seems to be the problem.
This seems to be due to restoresigs(); in exec.c and the fact that if a subshell contains only one command, there is an optimization to avoid a fork, as if there were an exec. Perhaps because of this optimization, the wrong set of signals are restored? But I wonder why the signals are restored (and what this does exactly). -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)