]> git.sesse.net Git - vlc/commitdiff
* ./src/interface/main.c: if Ctrl-C doesn't kill vlc cleanly for any
authorSam Hocevar <sam@videolan.org>
Thu, 9 May 2002 21:24:22 +0000 (21:24 +0000)
committerSam Hocevar <sam@videolan.org>
Thu, 9 May 2002 21:24:22 +0000 (21:24 +0000)
    reason, user just needs to hit Ctrl-C again 1 second later and we'll
    exit disgustingly instead of freezing.

src/interface/main.c

index 1887d894ebf1c6b269bd1b89f8b6893f8f1afab7..aa0592611a52d518773349deff9a706645f9a9f9 100644 (file)
@@ -4,7 +4,7 @@
  * and spawn threads.
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: main.c,v 1.189 2002/04/27 22:11:22 gbazin Exp $
+ * $Id: main.c,v 1.190 2002/05/09 21:24:22 sam Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -1130,21 +1130,40 @@ static void SimpleSignalHandler( int i_signal )
  *****************************************************************************/
 static void FatalSignalHandler( int i_signal )
 {
+    static mtime_t abort_time = 0;
+    static volatile boolean_t b_die = 0;
+
     /* Once a signal has been trapped, the termination sequence will be
      * armed and following signals will be ignored to avoid sending messages
      * to an interface having been destroyed */
+    if( !b_die )
+    {
+        b_die = 1;
+        abort_time = mdate();
+
+        /* Acknowledge the signal received */
+        intf_ErrMsg( "intf error: signal %d received, exiting - do it again "
+                     "if vlc gets stuck", i_signal );
+
+        /* Try to terminate everything - this is done by requesting the end
+         * of the interface thread */
+        p_main->p_intf->b_die = 1;
+
+        return;
+    }
+
+    /* If user asks again 1 second later, die badly */
+    if( mdate() > abort_time + 1000000 )
+    {
 #ifndef WIN32
-    signal( SIGINT,  SIG_IGN );
-    signal( SIGHUP,  SIG_IGN );
-    signal( SIGQUIT, SIG_IGN );
+        signal( SIGINT,  SIG_IGN );
+        signal( SIGHUP,  SIG_IGN );
+        signal( SIGQUIT, SIG_IGN );
 #endif
 
-    /* Acknowledge the signal received */
-    intf_ErrMsg( "intf error: signal %d received, exiting", i_signal );
-
-    /* Try to terminate everything - this is done by requesting the end of the
-     * interface thread */
-    p_main->p_intf->b_die = 1;
+        intf_ErrMsg( "intf error: user insisted too much, dying badly" );
+        exit( 1 );
+    }
 }
 
 /*****************************************************************************