]> git.sesse.net Git - mlt/commitdiff
Restore the terminal when melt exits abnormally
authorBrian Matherly <pez4brian@yahoo.com>
Wed, 20 Feb 2013 19:09:46 +0000 (13:09 -0600)
committerBrian Matherly <pez4brian@yahoo.com>
Wed, 20 Feb 2013 19:09:46 +0000 (13:09 -0600)
src/melt/melt.c

index 5196fafe36c58cfdfbf6e8ff422047c827874d98..f4ae780d1681c2f9a87809c56b334ef2b23a404f 100644 (file)
@@ -50,6 +50,15 @@ static void stop_handler(int signum)
        }
 }
 
+static void abnormal_exit_handler(int signum)
+{
+       // The process is going down hard. Restore the terminal first.
+       term_exit();
+       // Reset the default handler so the core gets dumped.
+       signal(signum, SIG_DFL);
+       kill(getpid(), signum);
+}
+
 static void transport_action( mlt_producer producer, char *value )
 {
        mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer );
@@ -681,6 +690,11 @@ int main( int argc, char **argv )
        int is_silent = 0;
        mlt_profile backup_profile;
 
+       // Handle abnormal exit situations.
+       signal( SIGSEGV, abnormal_exit_handler );
+       signal( SIGILL, abnormal_exit_handler );
+       signal( SIGABRT, abnormal_exit_handler );
+
        // Construct the factory
        mlt_repository repo = mlt_factory_init( NULL );