From: Brian Matherly Date: Wed, 20 Feb 2013 19:09:46 +0000 (-0600) Subject: Restore the terminal when melt exits abnormally X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=f20075c0ccf641f0da282140e3f4a3a55d7c4f92;p=mlt Restore the terminal when melt exits abnormally --- diff --git a/src/melt/melt.c b/src/melt/melt.c index 5196fafe..f4ae780d 100644 --- a/src/melt/melt.c +++ b/src/melt/melt.c @@ -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 );