Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

TRAPINT function set by parent shell causes subshell to misbehave



Hi,

Consider the following testcase:

$ (echo | less)
$ TRAPINT() { }
$ (echo | less)
$ (TRAPINT() { }; echo | less)

During the first execution of (echo | less) -- when a TRAPINT function
is not yet defined -- notice how sending ^C does not kill the 'less'
process or the subshell.

During the second execution of (echo | less) -- after a TRAPINT
function has been defined -- now sending ^C _does_ kill the subshell
(and the 'less' process along with it)

During the third execution of (echo | less) -- after a TRAPINT
function has been defined in the parent shell and redefined in the
subshell -- sending ^C no longer kills the subshell.

So when a TRAPINT function is defined in the parent shell and not
redefined in the subshell, then the subshell decides to exit when
SIGINT is sent to it -- at least when the 'less' command is run.  When
(echo | less) is replaced with e.g. (nano) then ^C does not kill the
subshell.  Nonetheless I would expect that the 2nd execution always
behaves like the 1st and 3rd executions.



Messages sorted by: Reverse Date, Date, Thread, Author