From 9ebdc16be6bf347dbd0b892f73f4e8329e970916 Mon Sep 17 00:00:00 2001 From: axel Date: Sun, 14 May 2006 20:16:23 +1000 Subject: Fix the longstanding hang-on-exit bug in eterm, as well as making sure the history is saved when the terminal emulator exits darcs-hash:20060514101623-ac50b-f8ce693ec111e3c158640ef8de309bf7e5484c5b.gz --- signal.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'signal.c') diff --git a/signal.c b/signal.c index 71ba0360..a679ae30 100644 --- a/signal.c +++ b/signal.c @@ -367,6 +367,7 @@ const wchar_t *signal_get_desc( int sig ) static void default_handler(int signal, siginfo_t *info, void *context) { event_t e; + e.type=EVENT_SIGNAL; e.param1.signal = signal; e.function_name=0; @@ -383,6 +384,22 @@ static void handle_winch( int sig, siginfo_t *info, void *context ) default_handler( sig, 0, 0 ); } +/** + Respond to a winch signal by checking the terminal size +*/ +static void handle_hup( int sig, siginfo_t *info, void *context ) +{ + if( event_signal_listen( SIGHUP ) ) + { + default_handler( sig, 0, 0 ); + } + else + { + reader_exit( 1, 1 ); + } + +} + /** Interactive mode ^C handler. Respond to int signal by setting interrupted-flag and stopping all loops and conditionals. @@ -479,7 +496,7 @@ void signal_set_handlers() wperror( L"sigaction" ); exit(1); } - + act.sa_flags = SA_SIGINFO; act.sa_sigaction= &handle_winch; if( sigaction( SIGWINCH, &act, 0 ) ) @@ -488,6 +505,14 @@ void signal_set_handlers() exit(1); } + act.sa_flags = SA_SIGINFO; + act.sa_sigaction= &handle_hup; + if( sigaction( SIGHUP, &act, 0 ) ) + { + wperror( L"sigaction" ); + exit(1); + } + } else { @@ -510,6 +535,7 @@ void signal_set_handlers() exit(1); } } + } void signal_handle( int sig, int do_handle ) -- cgit v1.2.3