]> git.sesse.net Git - vlc/commitdiff
After 3 seconds, allow SIGINT to kill the process
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 24 Jul 2010 10:44:27 +0000 (13:44 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 24 Jul 2010 10:45:24 +0000 (13:45 +0300)
Older versions did that too, and it can be quite useful when debugging.

bin/vlc.c

index 40fa96fbcaeb1d5636c0f1ffce27b66ae18a7f05..c8a05bae43d20b9bc8cbe8d2333ae99344aae2d1 100644 (file)
--- a/bin/vlc.c
+++ b/bin/vlc.c
@@ -74,6 +74,11 @@ static void vlc_kill (void *data)
     pthread_kill (*ps, SIGTERM);
 }
 
+static void exit_timeout (int signum)
+{
+    (void) signum;
+    signal (SIGINT, SIG_DFL);
+}
 
 /*****************************************************************************
  * main: parse command line, start interface and spawn threads.
@@ -221,6 +226,15 @@ int main( int i_argc, const char *ppsz_argv[] )
         sigwait (&set, &signum);
     while (signum == SIGCHLD);
 
+    /* Restore default signal behaviour after 3 seconds */
+    sigemptyset (&set);
+    sigaddset (&set, SIGINT);
+    sigaddset (&set, SIGALRM);
+    signal (SIGINT, SIG_IGN);
+    signal (SIGALRM, exit_timeout);
+    pthread_sigmask (SIG_UNBLOCK, &set, NULL);
+    alarm (3);
+
     /* Cleanup */
 out:
     if (vlc != NULL)