mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 10:51:15 -03:00
Restore terminal foreground process group on exit
Fixes https://github.com/fish-shell/fish-shell/issues/197
This commit is contained in:
17
signal.cpp
17
signal.cpp
@@ -458,6 +458,14 @@ static void handle_hup( int sig, siginfo_t *info, void *context )
|
||||
}
|
||||
}
|
||||
|
||||
/** Handle sigterm. The only thing we do is restore the front process ID, then die. */
|
||||
static void handle_term( int sig, siginfo_t *info, void *context )
|
||||
{
|
||||
restore_term_foreground_process_group();
|
||||
signal(SIGTERM, SIG_DFL);
|
||||
raise(SIGTERM);
|
||||
}
|
||||
|
||||
/**
|
||||
Interactive mode ^C handler. Respond to int signal by setting
|
||||
interrupted-flag and stopping all loops and conditionals.
|
||||
@@ -572,6 +580,15 @@ void signal_set_handlers()
|
||||
wperror( L"sigaction" );
|
||||
FATAL_EXIT();
|
||||
}
|
||||
|
||||
// SIGTERM restores the terminal controlling process before dying
|
||||
act.sa_flags = SA_SIGINFO;
|
||||
act.sa_sigaction= &handle_term;
|
||||
if( sigaction( SIGTERM, &act, 0 ) )
|
||||
{
|
||||
wperror( L"sigaction" );
|
||||
FATAL_EXIT();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user