Reset the terminal to our pgrp after groups, functions, and builtins, not just external command invocations.

This addresses a problem where something invoked in a group or function (e.g. gsh) could change the terminal's pgrp, and this would result in hush getting backgrounded.

We can still get strange behavior when a backgrounded child process changes the pgrp. Trying to deal with this would be inherently racy. Gsh also has problems in this scenario.
This commit is contained in:
Stephen Heumann 2014-12-28 11:35:31 -06:00
parent 9033a24562
commit 01dbfccea6

View File

@ -7985,6 +7985,11 @@ static int run_list(struct pipe *pi)
* and we don't need to wait for anything. */
G.last_exitcode = rcode;
debug_printf_exec((": builtin/func exitcode %d\n", rcode));
#if ENABLE_HUSH_JOB
if (G.run_list_level == 1 && G_interactive_fd) {
tc_set_to_my_pgrp(G_interactive_fd);
}
#endif
check_and_run_traps();
#if ENABLE_HUSH_LOOPS
/* Was it "break" or "continue"? */