[vlc-devel] commit: signals: ignore SIGHUP if its handler is SIG_IGN ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue Dec 8 22:16:19 CET 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Dec  8 23:13:39 2009 +0200| [7faec405d0b22f43e729e4fecac1302cbbe03015] | committer: Rémi Denis-Courmont 

signals: ignore SIGHUP if its handler is SIG_IGN

This works around GNU coreutils nohup not working with VLC.

Pointed-out-by: Gilles Chanteperdrix <gilles.chanteperdrix at xenomai.org>

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

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

diff --git a/modules/control/signals.c b/modules/control/signals.c
index 7acf926..5cb6f36 100644
--- a/modules/control/signals.c
+++ b/modules/control/signals.c
@@ -84,6 +84,16 @@ static void Close (vlc_object_t *obj)
     free (p_sys);
 }
 
+static bool ignored (int signum)
+{
+    struct sigaction sa;
+
+    if (sigaction (signum, NULL, &sa))
+        return false;
+    return ((sa.sa_flags & SA_SIGINFO)
+            ? (void *)sa.sa_sigaction : (void *)sa.sa_handler) == SIG_IGN;
+}
+
 static void *SigThread (void *data)
 {
     intf_thread_t *obj = data;
@@ -91,7 +101,8 @@ static void *SigThread (void *data)
     int signum;
 
     sigemptyset (&set);
-    sigaddset (&set, SIGHUP);
+    if (!ignored (SIGHUP)) /* <- needed to handle nohup properly */
+        sigaddset (&set, SIGHUP);
     sigaddset (&set, SIGINT);
     sigaddset (&set, SIGQUIT);
     sigaddset (&set, SIGTERM);




More information about the vlc-devel mailing list