mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix crash/freeze upon interrupting command substitution with pipe
On some systems (at least Linux and macOS): 1. Run on a command line: t=$(sleep 10|while :; do :; done) 2. Press Ctrl+C in the first 10 seconds. 3. Execute any other command substitution. The shell crashes. Analysis: Something in the job_wait() call in the sh_subshell() restore routine may be interrupted by a signal such as SIGINT on Linux and macOS. Exactly what that interruptible thing is remains to be determined. In any case, since job_wait() was invoked after sh_popcontext(), interrupting it caused the sh_subshell() restore routine to be aborted, resulting in an inconsistent state of the shell. The fix is to sh_popcontext() at a later stage instead. src/cmd/ksh93/sh/subshell.c: sh_subshell(): - Rename struct checkpt buff to checkpoint because it's clearer. - Move the sh_popcontext() call to near the end, just after decreasing the subshell level counters and restoring the global subshell data struct to its parent. This seems like a logical place for it and could allow other things to be interrupted, too. - Get rid of the if(shp->subshell) because it is known that the value is > 0 at this point. - The short exit routine run if the subshell forked now needs a new sh_popcontext() call, because this is handled before restoring the virtual subshell state. - While we're here, do a little more detransitioning from all those pointless shp pointers. Fixes: https://github.com/ksh93/ksh/issues/397
This commit is contained in:
parent
f7213f03a2
commit
91a7c2e3e9
3 changed files with 16 additions and 13 deletions
5
NEWS
5
NEWS
|
@ -3,6 +3,11 @@ For full details, see the git log at: https://github.com/ksh93/ksh
|
|||
|
||||
Any uppercase BUG_* names are modernish shell bug IDs.
|
||||
|
||||
2021-12-27:
|
||||
|
||||
- Fixed a crash or freeze that would occur on Linux when using Ctrl+C to
|
||||
interrupt a command substitution containing a pipe in an interactive shell.
|
||||
|
||||
2021-12-26:
|
||||
|
||||
- Listing aliases or tracked aliases in a script no longer corrupts
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue