1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix crash: do not list jobs if there is no job control

This bug caused an undefined state, which sometimes crashed the
shell in job_list() or job_unpost(), if $PS1 contains a command
substitution running an external command and the '-b'/'-o notify'
shell option is active. So far the only known way to trigger the
crash is by letting $TMOUT time out the interactive shell. See
https://github.com/ksh93/ksh/issues/103 for details.

src/cmd/ksh93/sh/jobs.c: job_reap():
- The check for the SH_NOTIFY option and the SH_TTYWAIT state
  before listing jobs was insufficient. Job control is disabled in
  command substitutions, so also check that job control is active
  before listing jobs.

src/cmd/ksh93/sh.1:
- Fix TMOUT documentation. The 'read' command in fact only times
  out when reading from a terminal, just like 'select'. Also
  document the extra 60 second grace period when an interactive
  shell prompt reads from a terminal.

Fixes: https://github.com/ksh93/ksh/issues/103
This commit is contained in:
Martijn Dekker 2020-08-06 22:46:02 +01:00
parent 49ae483574
commit 338586896d
4 changed files with 12 additions and 11 deletions

5
NEWS
View file

@ -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.
2020-08-06:
- Fixed a crash that occurred intermittently if 'set -b'/'set -o notify' is
active and $PS1 contains a command substitution running an external command.
2020-08-05:
- Fixed a bug in functions that caused ksh to crash when an array with an

View file

@ -17,4 +17,4 @@
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#define SH_RELEASE "93u+m 2020-08-05"
#define SH_RELEASE "93u+m 2020-08-06"

View file

@ -2185,20 +2185,16 @@ is used. If the value is null, no timing information is displayed.
.TP
.B
.SM TMOUT
If set to a value greater than zero,
.B
.SM TMOUT
will be the default timeout value for the
Terminal read timeout. If set to a value greater than zero, the
.B read
built-in command.
The
built-in command and the
.B select
compound command terminates after
compound command time out after
.B
.SM TMOUT
seconds when input is from a terminal.
Otherwise,
the shell will terminate if a line is not entered within
An interactive shell will issue a warning and allow for an extra 60 second
timeout grace period before terminating if a line is not entered within
the prescribed number of seconds while reading from a terminal.
(Note that the shell can be compiled with a maximum bound
for this value which cannot be exceeded.)

View file

@ -460,7 +460,7 @@ int job_reap(register int sig)
nochild = 1;
}
shp->gd->waitevent = waitevent;
if(sh_isoption(SH_NOTIFY) && sh_isstate(SH_TTYWAIT))
if(job.jobcontrol && sh_isoption(SH_NOTIFY) && sh_isstate(SH_TTYWAIT))
{
outfile = sfstderr;
job_list(pw,JOB_NFLAG|JOB_NLFLAG);