Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow kill built-in to terminate interactive shell
Reproducer: $ kill -s HUP $$ $ Since the signal is not SIGTERM or SIGQUIT and is not trapped, even the interactive shell should terminate, but ksh happily returns to the prompt. The exit status reflects that SIGHUP was sent, but the interactive shell fails to exit when the 'kill' built-in is used. Oddly enough, the external 'kill' command works fine: $ command -x kill -s HUP $$ Hangup On every other shell, the kill built-in also works as expected. Analysis: in sh_fault(), when processing a signal flagged with SH_DONE (terminates the shell by default), the mode flag in sh.jmplist (the longjmp return stack) is set to SH_JMPSUB or SH_JMPFUN, values used for returning from virtual subshells and ksh-style functions, relatively. But those will not cause the shell to exit as expected. For that, we need SH_JMPEXIT (see main.c line 628-629). src/cmd/ksh93/sh/fault.c: sh_fault(): - Make sure the SH_JMPEXIT longjmp return mode is used when the shell is in the SH_INTERACTIVE state. (Note that, as of 48ba696, this state bit is alwayas off in subshells, so this change does not affect subshells of interactive shells.)
- Loading branch information