diff --git a/fish.cpp b/fish.cpp index 8235c529f..4f2a3ca6f 100644 --- a/fish.cpp +++ b/fish.cpp @@ -365,18 +365,12 @@ static int fish_parse_opt(int argc, char **argv, std::vector *out_c is_login |= (strcmp(argv[0], "-fish") == 0); - /* - We are an interactive session if we have not been given an - explicit command to execute, _and_ stdin is a tty. - */ - is_interactive_session &= ! has_cmd; - is_interactive_session &= (my_optind == argc); - is_interactive_session &= isatty(STDIN_FILENO); - - /* - We are also an interactive session if we have are forced- - */ - is_interactive_session |= force_interactive; + /* We are an interactive session if we are either forced, or have not been given an explicit command to execute and stdin is a tty. */ + if (force_interactive) { + is_interactive_session = true; + } else if (is_interactive_session) { + is_interactive_session = ! has_cmd && (my_optind == argc) && isatty(STDIN_FILENO); + } return my_optind; } @@ -408,7 +402,7 @@ int main(int argc, char **argv) debug(1, _(L"Can not use the no-execute mode when running an interactive session")); no_exec = 0; } - + /* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */ if (is_interactive_session) { @@ -515,7 +509,7 @@ int main(int argc, char **argv) } proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res); - + restore_term_mode(); restore_term_foreground_process_group(); history_destroy(); diff --git a/fishd.cpp b/fishd.cpp index edb79c22f..5e2a36483 100644 --- a/fishd.cpp +++ b/fishd.cpp @@ -694,7 +694,7 @@ static void daemonize() } /* - Put ourself in out own processing group + Put ourself in our own process group */ setsid();