[vlc-commits] commit: After 3 seconds, allow SIGINT to kill the process ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Sat Jul 24 12:45:27 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jul 24 13:44:27 2010 +0300| [e1c2b18a4dfbf07e32730ac1fc3a6ed153099ca5] | committer: Rémi Denis-Courmont 

After 3 seconds, allow SIGINT to kill the process

Older versions did that too, and it can be quite useful when debugging.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e1c2b18a4dfbf07e32730ac1fc3a6ed153099ca5
---

 bin/vlc.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/bin/vlc.c b/bin/vlc.c
index 40fa96f..c8a05ba 100644
--- 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)



More information about the vlc-commits mailing list