[vlc-devel] commit: signals: let the default handlers kill VLC after 3 seconds ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun May 3 19:52:06 CEST 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun May  3 20:50:19 2009 +0300| [63a901056a9d3df3986546d87fb7c19d53190122] | committer: Rémi Denis-Courmont 

signals: let the default handlers kill VLC after 3 seconds

This should only be used if VLC deadlocks, or takes an awfully long time
to clean up. That will let VLC be killed as with the older signals
handler.

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

 modules/control/signals.c |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/modules/control/signals.c b/modules/control/signals.c
index f1f4b3c..7b63cbc 100644
--- a/modules/control/signals.c
+++ b/modules/control/signals.c
@@ -88,6 +88,7 @@ static void *SigThread (void *data)
 {
     intf_thread_t *obj = data;
     sigset_t set;
+    int signum;
 
     sigemptyset (&set);
     sigaddset (&set, SIGHUP);
@@ -97,10 +98,8 @@ static void *SigThread (void *data)
 
     sigaddset (&set, SIGCHLD);
 
-    for (;;)
+    do
     {
-        int signum;
-
         sigwait (&set, &signum);
 
 #ifdef __APPLE__
@@ -108,17 +107,15 @@ static void *SigThread (void *data)
          * cancellation point */
         vlc_testcancel();
 #endif
-
-        switch (signum)
-        {
-            case SIGINT:
-            case SIGHUP:
-            case SIGTERM:
-            case SIGQUIT:
-                msg_Err (obj, "Caught %s signal, exiting...",
-                         strsignal (signum));
-                libvlc_Quit (obj->p_libvlc);
-                break;
-        }
     }
+    while (signum == SIGCHLD);
+
+    msg_Err (obj, "Caught %s signal, exiting...", strsignal (signum));
+    libvlc_Quit (obj->p_libvlc);
+
+    /* After 3 seconds, fallback to normal signal handling */
+    msleep (3 * CLOCK_FREQ);
+    pthread_sigmask (SIG_UNBLOCK, &set, NULL);
+    for (;;)
+        pause ();
 }




More information about the vlc-devel mailing list