aboutsummaryrefslogtreecommitdiffhomepage
path: root/signal.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-05-14 20:16:23 +1000
committerGravatar axel <axel@liljencrantz.se>2006-05-14 20:16:23 +1000
commit9ebdc16be6bf347dbd0b892f73f4e8329e970916 (patch)
treec89e80559a598f5c2423e2210082e0a06bc3fa95 /signal.c
parent92ecc01baa1e762bc726dc51145434137efc65d4 (diff)
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
Diffstat (limited to 'signal.c')
-rw-r--r--signal.c28
1 files changed, 27 insertions, 1 deletions
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;
@@ -384,6 +385,22 @@ static void handle_winch( int sig, siginfo_t *info, void *context )
}
/**
+ 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 )