[vlc-commits] vlc: use signal handlers rather than sigwait() for SIGCHLD

Rémi Denis-Courmont git at videolan.org
Thu Feb 3 13:57:52 CET 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Feb  3 14:57:00 2011 +0200| [d1ca34ed5b81ce60adb6140a90c042d1ec4234e3] | committer: Rémi Denis-Courmont

vlc: use signal handlers rather than sigwait() for SIGCHLD

This works around Qt4 QProcess getting stuck waiting for its
SIGCHLD signal handler to be called.

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

 bin/vlc.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/bin/vlc.c b/bin/vlc.c
index 2094cdc..3a49287 100644
--- 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);



More information about the vlc-commits mailing list