]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
daemon: don't use SIGSTOP when using Upstart
authorVincent Bernat <vincent@bernat.im>
Sat, 30 Sep 2017 10:48:33 +0000 (12:48 +0200)
committerVincent Bernat <vincent@bernat.im>
Mon, 2 Oct 2017 20:00:15 +0000 (22:00 +0200)
This is buggy because if lldpd happens to stop before sending SIGSTOP,
Upstart won't respawn it. See:
 https://bugs.launchpad.net/upstart/+bug/712351

Instead, let Upstart detects the double fork. This should work just
fine as there is no "trap" before daemonizing.

Fix #245

NEWS
debian/lldpd.upstart
src/daemon/lldpd.c

diff --git a/NEWS b/NEWS
index b07f29dda24c6f0469db91d16b13fd592f36acc5..40635946a1715494c327899a73faa3538ce8df11 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ lldpd (0.9.9)
       each of them ("show interfaces").
   * Fix:
     + Don't remove interfaces when they are released from a bridge.
+    + Don't use "expect stop" with Upstart. It's buggy.
 
 lldpd (0.9.8)
   * Changes:
index c41afbad4d6d0e54deca6639cd0fc9839f242c0f..9de68e06a6b4528add4a9ac6f15783beaeef1782 100644 (file)
@@ -9,7 +9,7 @@ description "LLDP daemon"
 start on net-device-up IFACE=lo
 stop on runlevel [06]
 
-expect stop
+expect daemon
 respawn
 
 script
index 45397fd365621f798233a5442bcab339e51cd42b..343870083f2657199ceb66428c0a20e30acbf805 100644 (file)
@@ -1343,25 +1343,6 @@ static const struct intint filters[] = {
 };
 
 #ifndef HOST_OS_OSX
-/**
- * Tell if we have been started by upstart.
- */
-static int
-lldpd_started_by_upstart()
-{
-#ifdef HOST_OS_LINUX
-       const char *upstartjob = getenv("UPSTART_JOB");
-       if (!(upstartjob && !strcmp(upstartjob, "lldpd")))
-               return 0;
-       log_debug("main", "running with upstart, don't fork but stop");
-       raise(SIGSTOP);
-       unsetenv("UPSTART_JOB");
-       return 1;
-#else
-       return 0;
-#endif
-}
-
 /**
  * Tell if we have been started by systemd.
  */
@@ -1667,7 +1648,7 @@ lldpd_main(int argc, char *argv[], char *envp[])
        tzset();                /* Get timezone info before chroot */
        if (use_syslog && daemonize) {
                /* So, we use syslog and we daemonize (or we are started by
-                * upstart/systemd). No need to continue writing to stdout. */
+                * systemd). No need to continue writing to stdout. */
                int fd;
                if ((fd = open("/dev/null", O_RDWR, 0)) != -1) {
                        dup2(fd, STDIN_FILENO);
@@ -1730,10 +1711,10 @@ lldpd_main(int argc, char *argv[], char *envp[])
        /* Disable SIGHUP, until handlers are installed */
        signal(SIGHUP, SIG_IGN);
 
-       /* Daemonization, unless started by upstart, systemd or launchd or debug */
+       /* Daemonization, unless started by systemd or launchd or debug */
 #ifndef HOST_OS_OSX
        if (daemonize &&
-           !lldpd_started_by_upstart() && !lldpd_started_by_systemd()) {
+           !lldpd_started_by_systemd()) {
                int pid;
                char *spid;
                log_debug("main", "going into background");