From: Chet Ramey Date: Thu, 9 Nov 2023 21:45:56 +0000 (-0500) Subject: Bash-5.2 patch 19: fix case where background job set the terminal process group X-Git-Tag: bash-5.3-alpha~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f4cb298c0226a530ffd4bdc83763e848499370f8;p=thirdparty%2Fbash.git Bash-5.2 patch 19: fix case where background job set the terminal process group --- diff --git a/jobs.c b/jobs.c index 45869dd81..b96230fa7 100644 --- a/jobs.c +++ b/jobs.c @@ -3077,9 +3077,13 @@ if (job == NO_JOB) /* Don't modify terminal pgrp if we are running in background or a subshell. Make sure subst.c:command_substitute uses the same conditions to determine whether or not it should undo this and - give the terminal to pipeline_pgrp. */ - + give the terminal to pipeline_pgrp. We don't give the terminal + back to shell_pgrp if an async job in the background exits because + we never gave it to that job in the first place. An async job in + the foreground is one we started in the background and foregrounded + with `fg', and gave it the terminal. */ if ((flags & JWAIT_NOTERM) == 0 && running_in_background == 0 && + (job == NO_JOB || IS_ASYNC (job) == 0 || IS_FOREGROUND (job)) && (subshell_environment & (SUBSHELL_ASYNC|SUBSHELL_PIPE)) == 0) give_terminal_to (shell_pgrp, 0); } @@ -3623,6 +3627,7 @@ start_job (job, foreground) { get_tty_state (); save_stty = shell_tty_info; + jobs[job]->flags &= ~J_ASYNC; /* no longer async */ /* Give the terminal to this job. */ if (IS_JOBCONTROL (job)) give_terminal_to (jobs[job]->pgrp, 0); diff --git a/patchlevel.h b/patchlevel.h index d4b06906b..88059dee0 100644 --- a/patchlevel.h +++ b/patchlevel.h @@ -25,6 +25,6 @@ regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh looks for to find the patch level (for the sccs version string). */ -#define PATCHLEVEL 18 +#define PATCHLEVEL 19 #endif /* _PATCHLEVEL_H_ */