[vlc-devel] [PATCH] Fix vlc when run with the nohup command.

Gilles Chanteperdrix gilles.chanteperdrix at xenomai.org
Sat Nov 21 01:20:05 CET 2009

The nohup command, part of the GNU coreutils packages, forks, sets
SIGHUP handler to SIG_IGN, then execs another command, expecting it to
ignore the SIGHUP signal.

This does not work with vlc, because vlc, in its signal handling loop
explicitely polls for the SIGHUP signal. The following patch attempts
to fix this.
 modules/control/signals.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/modules/control/signals.c b/modules/control/signals.c
index 7acf926..794dc27 100644
--- a/modules/control/signals.c
+++ b/modules/control/signals.c
@@ -87,11 +87,15 @@ static void Close (vlc_object_t *obj)
 static void *SigThread (void *data)
     intf_thread_t *obj = data;
+    struct sigaction sa;
     sigset_t set;
     int signum;
     sigemptyset (&set);
-    sigaddset (&set, SIGHUP);
+    sigaction(SIGHUP, NULL, &sa);
+    if (!(sa.sa_flags & SA_SIGINFO) && sa.sa_handler != SIG_IGN
+	|| (sa.sa_flags & SA_SIGINFO) && sa.sa_sigaction != SIG_IGN)
+	    sigaddset (&set, SIGHUP);
     sigaddset (&set, SIGINT);
     sigaddset (&set, SIGQUIT);
     sigaddset (&set, SIGTERM);

More information about the vlc-devel mailing list