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
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
||||
#define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
|
||||
#define SH_RELEASE_DATE "2021-12-26" /* must be in this format for $((.sh.version)) */
|
||||
#define SH_RELEASE_DATE "2021-12-27" /* must be in this format for $((.sh.version)) */
|
||||
#define SH_RELEASE_CPYR "(c) 2020-2021 Contributors to ksh " SH_RELEASE_FORK
|
||||
|
||||
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue