aboutsummaryrefslogtreecommitdiffhomepage
path: root/signal.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-06-04 14:20:01 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-06-04 14:20:01 -0700
commit69446be1ee063771f2e0b498a50f9b0787ea70c7 (patch)
treebe5ecf3a473052475218df605d350a204666c750 /signal.cpp
parentcc90f9cf803bc4aba928b2a80be451d9b717c5f0 (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.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/signal.cpp b/signal.cpp
index 83a4b13e..dec6187e 100644
--- a/signal.cpp
+++ b/signal.cpp
@@ -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);
+ }
}
/**