]> git.sesse.net Git - vlc/commitdiff
vlc: use signal handlers rather than sigwait() for SIGCHLD
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 3 Feb 2011 12:57:00 +0000 (14:57 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 3 Feb 2011 12:57:00 +0000 (14:57 +0200)
This works around Qt4 QProcess getting stuck waiting for its
SIGCHLD signal handler to be called.

bin/vlc.c

index 2094cdc75498faeb1dad7591a6a5fa17f46c21ee..3a492873248955d225aa1185c1c9155f24b642a1 100644 (file)
--- a/bin/vlc.c
+++ b/bin/vlc.c
@@ -221,14 +221,19 @@ int main( int i_argc, const char *ppsz_argv[] )
     pthread_t self = pthread_self ();
     libvlc_set_exit_handler (vlc, vlc_kill, &self);
 
-    if (signal_ignored (SIGHUP)) /* <- needed to handle nohup properly */
+    /* Qt4 insists on catching SIGCHLD via signal handler. To work around that,
+     * unblock it after all our child threads are created. */
+    sigdelset (&set, SIGCHLD);
+    pthread_sigmask (SIG_SETMASK, &set, NULL);
+
+    /* Do not dequeue SIGHUP if it is ignored (nohup) */
+    if (signal_ignored (SIGHUP))
         sigdelset (&set, SIGHUP);
+    /* Ignore SIGPIPE */
     sigdelset (&set, SIGPIPE);
 
     int signum;
-    do
-        sigwait (&set, &signum);
-    while (signum == SIGCHLD);
+    sigwait (&set, &signum);
 
     /* Restore default signal behaviour after 3 seconds */
     sigemptyset (&set);