>From c4fdfa2874685685a0ba46516173abf2b5ba43ef Mon Sep 17 00:00:00 2001 From: Tom Levy <> Date: Thu, 7 Mar 2019 04:58:18 +0000 Subject: [PATCH] fix ^D: don't exit while jobs are stopped after intervening command --- builtins/exit.def | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/builtins/exit.def b/builtins/exit.def index 5167b2e0..193a6a59 100644 --- a/builtins/exit.def +++ b/builtins/exit.def @@ -51,6 +51,7 @@ $END extern int check_jobs_at_exit; static int exit_or_logout __P((WORD_LIST *)); +static int is_exit_attempt __P((sh_builtin_func_t *)); static int sourced_logout; int @@ -103,9 +104,8 @@ exit_or_logout (list) int exit_immediate_okay, stopmsg; exit_immediate_okay = (interactive == 0 || - last_shell_builtin == exit_builtin || - last_shell_builtin == logout_builtin || - last_shell_builtin == jobs_builtin); + (is_exit_attempt (this_shell_builtin) && + is_exit_attempt (last_shell_builtin))); /* Check for stopped jobs if the user wants to. */ if (exit_immediate_okay == 0) @@ -155,6 +155,15 @@ exit_or_logout (list) /*NOTREACHED*/ } +static int +is_exit_attempt (function) + sh_builtin_func_t *function; +{ + return (function == exit_builtin || + function == logout_builtin || + function == jobs_builtin); +} + void bash_logout () { -- 2.11.0