diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-06-04 14:20:01 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-06-04 14:20:01 -0700 |
commit | 69446be1ee063771f2e0b498a50f9b0787ea70c7 (patch) | |
tree | be5ecf3a473052475218df605d350a204666c750 /signal.cpp | |
parent | cc90f9cf803bc4aba928b2a80be451d9b717c5f0 (diff) |
Signal handling cleanup and improved safety
Fixes issue where you couldn't control-C out of a loop (https://github.com/ridiculousfish/fishfish/issues/13)
Also stops doing memory allocation in the signal handler (oops) https://github.com/ridiculousfish/fishfish/issues/27
Diffstat (limited to 'signal.cpp')
-rw-r--r-- | signal.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -427,10 +427,9 @@ const wchar_t *signal_get_desc( int sig ) */ static void default_handler(int signal, siginfo_t *info, void *context) { - event_t e = event_t::signal_event(signal); - if( event_get( &e, 0 ) ) - { - event_fire( &e ); + if (event_is_signal_observed(signal)) + { + event_fire_signal(signal); } } @@ -449,16 +448,14 @@ static void handle_winch( int sig, siginfo_t *info, void *context ) */ static void handle_hup( int sig, siginfo_t *info, void *context ) { - event_t e = event_t::signal_event(SIGHUP); - if( event_get( &e, 0 ) ) + if (event_is_signal_observed(SIGHUP)) { - default_handler( sig, 0, 0 ); + default_handler(sig, 0, 0); } else { - reader_exit( 1, 1 ); - } - + reader_exit(1, 1); + } } /** |