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:
parent
39692fc3f6
commit
fc655f1a26
4 changed files with 26 additions and 3 deletions
4
NEWS
4
NEWS
|
@ -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.
|
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:
|
2020-07-13:
|
||||||
|
|
||||||
- Fixed a fork bomb that could occur when the vi editor was sent SIGTSTP
|
- Fixed a fork bomb that could occur when the vi editor was sent SIGTSTP
|
||||||
|
|
|
@ -17,4 +17,4 @@
|
||||||
* David Korn <dgk@research.att.com> *
|
* David Korn <dgk@research.att.com> *
|
||||||
* *
|
* *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
#define SH_RELEASE "93u+m 2020-07-13"
|
#define SH_RELEASE "93u+m 2020-07-14"
|
||||||
|
|
|
@ -344,6 +344,7 @@ int job_reap(register int sig)
|
||||||
int nochild=0, oerrno, wstat;
|
int nochild=0, oerrno, wstat;
|
||||||
Waitevent_f waitevent = shp->gd->waitevent;
|
Waitevent_f waitevent = shp->gd->waitevent;
|
||||||
static int wcontinued = WCONTINUED;
|
static int wcontinued = WCONTINUED;
|
||||||
|
int was_ttywait_on;
|
||||||
#if SHOPT_COSHELL
|
#if SHOPT_COSHELL
|
||||||
Cojob_t *cjp;
|
Cojob_t *cjp;
|
||||||
int cojobs;
|
int cojobs;
|
||||||
|
@ -374,11 +375,13 @@ int job_reap(register int sig)
|
||||||
flags = WUNTRACED|wcontinued;
|
flags = WUNTRACED|wcontinued;
|
||||||
shp->gd->waitevent = 0;
|
shp->gd->waitevent = 0;
|
||||||
oerrno = errno;
|
oerrno = errno;
|
||||||
|
was_ttywait_on = sh_isstate(SH_TTYWAIT); /* save tty wait state */
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
if(!(flags&WNOHANG) && !sh.intrap && job.pwlist)
|
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))
|
if(waitevent && (*waitevent)(-1,-1L,0))
|
||||||
flags |= WNOHANG;
|
flags |= WNOHANG;
|
||||||
}
|
}
|
||||||
|
@ -404,7 +407,8 @@ int job_reap(register int sig)
|
||||||
}
|
}
|
||||||
#endif /* SHOPT_COSHELL */
|
#endif /* SHOPT_COSHELL */
|
||||||
pid = waitpid((pid_t)-1,&wstat,flags);
|
pid = waitpid((pid_t)-1,&wstat,flags);
|
||||||
sh_offstate(SH_TTYWAIT);
|
if(!was_ttywait_on)
|
||||||
|
sh_offstate(SH_TTYWAIT);
|
||||||
#if SHOPT_COSHELL
|
#if SHOPT_COSHELL
|
||||||
cojob:
|
cojob:
|
||||||
#endif /* SHOPT_COSHELL */
|
#endif /* SHOPT_COSHELL */
|
||||||
|
@ -559,6 +563,10 @@ int job_reap(register int sig)
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
if(errno==ECHILD)
|
||||||
{
|
{
|
||||||
errno = oerrno;
|
errno = oerrno;
|
||||||
|
|
|
@ -549,5 +549,16 @@ r ^:test-2: true string\\r\\n$
|
||||||
!
|
!
|
||||||
done
|
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))
|
exit $((Errors<125?Errors:125))
|
||||||
|
|
Loading…
Reference in a new issue