1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 11:42:21 +00:00

Restore 'set -b'/'set -o notify' functionality (#74)

'set -b' had no effect; it should cause the shell to notify job
state changes immediately instead of waiting for the next prompt.

This fixes a regression that was introduced in ksh93t 2008-07-25.
The bugfix is from: https://github.com/att/ast/pull/1089

src/cmd/ksh93/sh/jobs.c:
- Save the tty wait state and avoid changing it if TTYWAIT was
  already on to avoid breaking 'set -b'.
  The last 'sh_offstate' is inside of an '#if' directive because it
  is only required when ksh is compiled with SHOPT_COSHELL enabled.

src/cmd/ksh93/tests/pty.sh:
- Add a regression test for 'set -b' in interactive shells.
This commit is contained in:
Johnothan King 2020-07-14 14:00:28 -07:00 committed by GitHub
parent 39692fc3f6
commit fc655f1a26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 3 deletions

4
NEWS
View file

@ -3,6 +3,10 @@ For full details, see the git log at: https://github.com/ksh93/ksh
Any uppercase BUG_* names are modernish shell bug IDs.
2020-07-14:
- Fixed a bug that caused 'set -b' to have no effect.
2020-07-13:
- Fixed a fork bomb that could occur when the vi editor was sent SIGTSTP

View file

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

View file

@ -344,6 +344,7 @@ int job_reap(register int sig)
int nochild=0, oerrno, wstat;
Waitevent_f waitevent = shp->gd->waitevent;
static int wcontinued = WCONTINUED;
int was_ttywait_on;
#if SHOPT_COSHELL
Cojob_t *cjp;
int cojobs;
@ -374,11 +375,13 @@ int job_reap(register int sig)
flags = WUNTRACED|wcontinued;
shp->gd->waitevent = 0;
oerrno = errno;
was_ttywait_on = sh_isstate(SH_TTYWAIT); /* save tty wait state */
while(1)
{
if(!(flags&WNOHANG) && !sh.intrap && job.pwlist)
{
sh_onstate(SH_TTYWAIT);
if(!was_ttywait_on)
sh_onstate(SH_TTYWAIT);
if(waitevent && (*waitevent)(-1,-1L,0))
flags |= WNOHANG;
}
@ -404,7 +407,8 @@ int job_reap(register int sig)
}
#endif /* SHOPT_COSHELL */
pid = waitpid((pid_t)-1,&wstat,flags);
sh_offstate(SH_TTYWAIT);
if(!was_ttywait_on)
sh_offstate(SH_TTYWAIT);
#if SHOPT_COSHELL
cojob:
#endif /* SHOPT_COSHELL */
@ -559,6 +563,10 @@ int job_reap(register int sig)
}
#endif
}
#if SHOPT_COSHELL
if(!was_ttywait_on)
sh_offstate(SH_TTYWAIT); /* only required after 'goto cojob' in the while loop */
#endif
if(errno==ECHILD)
{
errno = oerrno;

View file

@ -549,5 +549,16 @@ r ^:test-2: true string\\r\\n$
!
done
# err_exit #
tst $LINENO <<"!"
L notify job state changes
# 'set -b' should immediately notify the user about job state changes.
p :test-1:
w set -b; sleep .01 &
u Done
!
# ======
exit $((Errors<125?Errors:125))