diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-11-18 02:16:14 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-11-18 02:16:14 -0800 |
commit | c9c2fc5ee346e15e934dd72ed08774d769cfd7a1 (patch) | |
tree | 0746962ac6267fcccb25eb6950074450d7bbc47d /signal.cpp | |
parent | b79854ad1aa814d9d35d76a1929b4726fa4bffa5 (diff) |
Restore terminal foreground process group on exit
Diffstat (limited to 'signal.cpp')
-rw-r--r-- | signal.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -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 |