1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00
cde/src/cmd/ksh93/include
Martijn Dekker 2c35a53964 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.
2022-01-28 05:15:42 +00:00
..
argnod.h [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
builtins.h [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
defs.h bump internal libast version; various minor cleanups 2022-01-14 19:55:35 +00:00
edit.h edit: do not enable multiline mode with no editor active 2022-01-12 20:39:05 +00:00
fault.h Some more accumulated minor tweaks and cleanups 2022-01-25 16:13:15 +00:00
fcin.h INIT: remove proto, ratz (re: 46593a89, 6137b99a); major cleanup 2021-12-24 07:05:22 +00:00
history.h [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
io.h [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
jobs.h Fix various typos, man page issues and improve the documentation (#415) 2022-01-07 16:17:55 +00:00
lexstates.h INIT: remove proto, ratz (re: 46593a89, 6137b99a); major cleanup 2021-12-24 07:05:22 +00:00
name.h Fix multiple bugs when using 'alias -p' to print aliases (#398) 2021-12-27 03:49:06 +00:00
national.h INIT: remove proto, ratz (re: 46593a89, 6137b99a); major cleanup 2021-12-24 07:05:22 +00:00
nval.h Some more accumulated minor tweaks and cleanups 2022-01-25 16:13:15 +00:00
path.h [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
regress.h [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
shell.h Various minor cleanups and fixes 2022-01-20 00:54:42 +00:00
shlex.h Fix various typos, man page issues and improve the documentation (#415) 2022-01-07 16:17:55 +00:00
shnodes.h [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
shtable.h [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
streval.h [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
terminal.h Allow ksh to compile on Haiku; implement SIGKILLTHR support (#408) 2022-01-07 16:16:42 +00:00
test.h [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
timeout.h Add ksh 93u+m contributors notice to 964 copyright headers 2021-04-26 00:19:31 +01:00
ulimit.h Add three options to 'ulimit' (#406) 2021-12-28 22:02:20 +00:00
variables.h [shp cleanup 01..20] all the rest (re: 2d3ec8b6) 2022-01-07 16:16:31 +00:00
version.h Fix resuming external command run from POSIX function or dot script 2022-01-28 05:15:42 +00:00