All pastes #1064358 Raw Edit

signal handler 2

public diff v1 · immutable
#1064358 ·published 2008-07-07 04:49 UTC
rendered paste body
Index: test/test.c===================================================================--- test/test.c	(revision 1557)+++ test/test.c	(working copy)@@ -186,6 +186,11 @@     /* Exit ASAP on Ctrl-C */     signal( SIGINT, SigHandler ); +    /* Catch crashes and exit gracefully, if possible. */+    signal( SIGSEGV, SigHandler );+    signal( SIGBUS,  SigHandler );+    signal( SIGFPE,  SigHandler );+     /* Feed libhb with a DVD to scan */     fprintf( stderr, "Opening %s...\n", input ); @@ -1397,12 +1402,17 @@ static volatile int64_t i_die_date = 0; void SigHandler( int i_signal ) {+    if( i_signal != SIGINT )+    {+        hb_error( "HandBrake has crashed on signal %d...", i_signal );+    }+     if( die == 0 )     {         die = 1;         i_die_date = hb_get_date();         fprintf( stderr, "Signal %d received, terminating - do it "-                 "again in case it gets stuck\n", i_signal );+                 "again if it gets stuck\n", i_signal );     }     else if( i_die_date + 500 < hb_get_date() )     {Index: macosx/main.mm===================================================================--- macosx/main.mm	(revision 1557)+++ macosx/main.mm	(working copy)@@ -7,10 +7,6 @@ #include <Cocoa/Cocoa.h> #import "hb.h" -void SigHandler( int signal )-{-    [NSApp terminate: NULL];-}   /****************************************************************************  * hb_error_handler@@ -25,9 +21,22 @@ } } +void SigHandler( int signal )+{+    if( signal != SIGINT )+    {+        hb_error_handler( "HandBrake has crashed..." );+    }+    [NSApp terminate: NULL];+}+  int main( int argc, const char ** argv ) {     signal( SIGINT, SigHandler );+    signal( SIGBUS, SigHandler );+    signal( SIGSEGV, SigHandler );+    signal( SIGFPE, SigHandler );+         hb_register_error_handler(&hb_error_handler);     return NSApplicationMain( argc, argv ); }