mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-13 11:42:21 +00:00
Fix resuming external command run from POSIX function or dot script
This fixes yet another whopper of a bug in job control. And it's been in every version of ksh93 back to 1995, the beginning of ast-open-archive. <sigh> This is also bug number 23 that is fixed by simply removing code. Reproducer: 1. Run vi, or another suspendable program, from a dot script or POSIX function (ksh handles them the same way). So either: $ echo vi >v $ . ./v or: $ v() { vi; } $ v 2. Suspend vi by typing Ctrl+Z. 3. Not one but two jobs are registered: $ jobs -l [2] + 85513 Stopped . ./v [1] - 85512 Stopped . ./v 4. 'fg' does not work on either of them, just printing the job command name but not resuming the editor. The second job disappears from the table after 'fg'. $ fg %2 . ./v $ fg %2 ksh: fg: no such job $ fg %1 . ./v $ fg %1 . ./v Either way, you're stuck with an unresumable vi that you have to 'kill -9' manually. src/cmd/ksh93/sh/xec.c: sh_exec(): TFORK: - Do *not* turn off the SH_MONITOR state flag (which tells ksh to keep track of jobs) when running an external command from a profile script or dot script/POSIX function. It's obvious that this results in an inconsistent job control state as ksh will not update it when the external command is suspended. The purpose of this nonsense is surely lost to history as it's been there since 1995 or before. My testing says that removing it doesn't break anything. If that turns out to be wrong, then the breakage will have to be fixed in a correct way instead.
This commit is contained in:
parent
3f07ac1d95
commit
2c35a53964
3 changed files with 7 additions and 11 deletions
6
NEWS
6
NEWS
|
@ -3,6 +3,12 @@ For full details, see the git log at: https://github.com/ksh93/ksh/tree/1.0
|
||||||
|
|
||||||
Any uppercase BUG_* names are modernish shell bug IDs.
|
Any uppercase BUG_* names are modernish shell bug IDs.
|
||||||
|
|
||||||
|
2022-01-28:
|
||||||
|
|
||||||
|
- Fixed longstanding job control breakage that occurred on the interactive
|
||||||
|
shell when suspending (Ctrl+Z) an external command invoked by a dot script
|
||||||
|
or POSIX shell function.
|
||||||
|
|
||||||
2022-01-26:
|
2022-01-26:
|
||||||
|
|
||||||
- On Cygwin, ksh now executes scripts that do not have a #! path itself,
|
- On Cygwin, ksh now executes scripts that do not have a #! path itself,
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */
|
#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_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */
|
||||||
#define SH_RELEASE_DATE "2022-01-26" /* must be in this format for $((.sh.version)) */
|
#define SH_RELEASE_DATE "2022-01-28" /* must be in this format for $((.sh.version)) */
|
||||||
#define SH_RELEASE_CPYR "(c) 2020-2022 Contributors to ksh " SH_RELEASE_FORK
|
#define SH_RELEASE_CPYR "(c) 2020-2022 Contributors to ksh " SH_RELEASE_FORK
|
||||||
|
|
||||||
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
/* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */
|
||||||
|
|
|
@ -1586,16 +1586,6 @@ int sh_exec(register const Shnode_t *t, int flags)
|
||||||
&& !sh.st.trap[SH_ERRTRAP]
|
&& !sh.st.trap[SH_ERRTRAP]
|
||||||
&& ((struct checkpt*)sh.jmplist)->mode!=SH_JMPEVAL
|
&& ((struct checkpt*)sh.jmplist)->mode!=SH_JMPEVAL
|
||||||
&& (execflg2 || (execflg && sh.fn_depth==0 && !(pipejob && sh_isoption(SH_PIPEFAIL))));
|
&& (execflg2 || (execflg && sh.fn_depth==0 && !(pipejob && sh_isoption(SH_PIPEFAIL))));
|
||||||
if(sh_isstate(SH_PROFILE) || sh.dot_depth)
|
|
||||||
{
|
|
||||||
/* disable foreground job monitor */
|
|
||||||
if(!(type&FAMP))
|
|
||||||
sh_offstate(SH_MONITOR);
|
|
||||||
#if SHOPT_DEVFD
|
|
||||||
else if(!(type&FINT))
|
|
||||||
sh_offstate(SH_MONITOR);
|
|
||||||
#endif /* SHOPT_DEVFD */
|
|
||||||
}
|
|
||||||
if(no_fork)
|
if(no_fork)
|
||||||
job.parent=parent=0;
|
job.parent=parent=0;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue