mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
Fix for errant SIGHUPs due to child fish shells messing with the term.
Fixes https://github.com/fish-shell/fish-shell/issues/1002
This commit is contained in:
parent
e204ced1ae
commit
e05743d0ba
8
fish.cpp
8
fish.cpp
@ -389,7 +389,6 @@ int main(int argc, char **argv)
|
||||
|
||||
set_main_thread();
|
||||
setup_fork_guards();
|
||||
save_term_foreground_process_group();
|
||||
|
||||
wsetlocale(LC_ALL, L"");
|
||||
is_interactive_session=1;
|
||||
@ -410,6 +409,12 @@ int main(int argc, char **argv)
|
||||
no_exec = 0;
|
||||
}
|
||||
|
||||
/* Only save (and therefore restore) the fg process group if we are interactive. See #197, #1002 */
|
||||
if (is_interactive_session)
|
||||
{
|
||||
save_term_foreground_process_group();
|
||||
}
|
||||
|
||||
const struct config_paths_t paths = determine_config_directory_paths(argv[0]);
|
||||
|
||||
proc_init();
|
||||
@ -511,6 +516,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();
|
||||
proc_destroy();
|
||||
|
10
reader.cpp
10
reader.cpp
@ -993,10 +993,18 @@ void reader_init()
|
||||
|
||||
void reader_destroy()
|
||||
{
|
||||
tcsetattr(0, TCSANOW, &terminal_mode_on_startup);
|
||||
pthread_key_delete(generation_count_key);
|
||||
}
|
||||
|
||||
void restore_term_mode()
|
||||
{
|
||||
// Restore the term mode if we own the terminal
|
||||
// It's important we do this before restore_foreground_process_group, otherwise we won't think we own the terminal
|
||||
if (getpid() == tcgetpgrp(STDIN_FILENO))
|
||||
{
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &terminal_mode_on_startup);
|
||||
}
|
||||
}
|
||||
|
||||
void reader_exit(int do_exit, int forced)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user