Restore terminal foreground process group on exit

Fixes https://github.com/fish-shell/fish-shell/issues/197
This commit is contained in:
ridiculousfish
2012-11-18 02:16:14 -08:00
parent b79854ad1a
commit c9c2fc5ee3
6 changed files with 45 additions and 3 deletions

View File

@@ -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