diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index e3dc20d9..a667dbe9 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -6548,3 +6548,24 @@ subst.c - expand_string_dollar_quote: if singlequote_translations is set, there is a chance for a use-after-free of `t'. From a report by Grisha Levit + + 6/7 + --- +jobs.c,nojobs.c,jobs.h + - job_control_active_p: new function, returns 1 if job control is + currently enabled and we have given away the terminal + +builtins/evalstring.c + - should_suppress_fork: don't optimize away the fork if job control is + active because we need to call end_job_control and give the terminal + back to the original process group when this command finishes. Call + job_control_active_p() to check this. + Report from Andrew Hamon + + 6/8 + --- +shell.c + - ssh_run_startup_files: new variable, set by run_startup_files if + the shell decides it's being run by ssh and runs bashrc (only if + SSH_SOURCE_BASHRC is defined). Non-zero while the startup files + are being run. Not used by any other part of the shell yet. diff --git a/builtins/evalstring.c b/builtins/evalstring.c index 1b00da2e..11785de1 100644 --- a/builtins/evalstring.c +++ b/builtins/evalstring.c @@ -127,6 +127,7 @@ should_suppress_fork (COMMAND *command) return (startup_state == 2 && parse_and_execute_level == 1 && *bash_input.location.string == '\0' && parser_expanding_alias () == 0 && + job_control_active_p () == 0 && should_optimize_fork (command, subshell)); } diff --git a/jobs.c b/jobs.c index d3928518..1af63f9c 100644 --- a/jobs.c +++ b/jobs.c @@ -4977,6 +4977,12 @@ end_job_control (void) shell_pgrp = original_pgrp; } +int +job_control_active_p (void) +{ + return (job_control && original_pgrp != shell_pgrp && shell_pgrp == terminal_pgrp); +} + /* Restart job control by closing shell tty and reinitializing. This is called after an exec fails in an interactive shell and we do not exit. */ void diff --git a/jobs.h b/jobs.h index 5f9c9fc3..c6430216 100644 --- a/jobs.h +++ b/jobs.h @@ -309,6 +309,7 @@ extern void set_sigchld_handler (void); extern void ignore_tty_job_signals (void); extern void default_tty_job_signals (void); extern void get_original_tty_job_signals (void); +extern int job_control_active_p (void); extern void init_job_stats (void); diff --git a/lib/readline/util.c b/lib/readline/util.c index f909daaf..2a247034 100644 --- a/lib/readline/util.c +++ b/lib/readline/util.c @@ -43,8 +43,8 @@ #include /* System-specific feature definitions and include files. */ -#include "rldefs.h" #include "rlmbutil.h" +#include "rldefs.h" #if defined (TIOCSTAT_IN_SYS_IOCTL) # include diff --git a/nojobs.c b/nojobs.c index c480e860..6073d75a 100644 --- a/nojobs.c +++ b/nojobs.c @@ -1038,3 +1038,9 @@ count_all_jobs (void) { return 0; } + +int +job_control_active_p (void) +{ + return 0; +} diff --git a/shell.c b/shell.c index b1359eaf..9f1934d2 100644 --- a/shell.c +++ b/shell.c @@ -161,6 +161,8 @@ int autocd = 0; int startup_state = 0; int reading_shell_script = 0; +int ssh_reading_startup_files = 0; + /* Special debugging helper. */ int debugging_login_shell = 0; @@ -1128,6 +1130,7 @@ run_startup_files (void) if (isnetconn (fileno (stdin) && shell_level < 2) #endif { + ssh_reading_startup_files = 1; #ifdef SYS_BASHRC # if defined (__OPENNT) maybe_execute_file (_prefixInstallPath(SYS_BASHRC, NULL, 0), 1); @@ -1136,6 +1139,7 @@ run_startup_files (void) # endif #endif maybe_execute_file (bashrc_file, 1); + ssh_reading_startup_files = 0; return; } } diff --git a/shell.h b/shell.h index bf96786a..7b43813b 100644 --- a/shell.h +++ b/shell.h @@ -100,6 +100,7 @@ extern int executing, login_shell; extern int interactive, interactive_shell; extern int startup_state; extern int reading_shell_script; +extern int ssh_reading_startup_files; extern int shell_initialized; extern int bash_argv_initialized; extern int subshell_environment;