Bug 201749 - sys-process/daemontools-0.76-r5 - /etc/init.d/svscan stops supervise and svscan in the wrong order
Bug#: 201749 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: All Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: base-system@gentoo.org Reported By: tavin.cole@gmail.com
Component: Ebuilds
URL: 
Summary: sys-process/daemontools-0.76-r5 - /etc/init.d/svscan stops supervise and svscan in the wrong order
Keywords:  
Status Whiteboard: 
Opened: 2007-12-09 09:28 0000
Description:   Opened: 2007-12-09 09:28 0000
the following stop() function is run by /etc/init.d/svscan:

stop() {
        ebegin "Stopping service scan services"
        svc -dx /service/* 2>/dev/null
        eend $?
        ebegin "Stopping service scan logging"
        svc -dx /service/*/log 2>/dev/null
        eend $?
        ebegin "Stopping service scan"
        start-stop-daemon --stop --exec /usr/bin/svscan \
                --pidfile /var/run/svscan.pid
        eend $?
}

in between the time the supervise processes are killed by svc -dx, and the time
the svscan process is killed, svscan may spawn new supervise processes, since
that's what it's supposed to do every 5 seconds.  so you can potentially wind
up with a lot of unkilled daemons at shutdown time.

the fix is simple, just kill svscan first:

stop() {
        ebegin "Stopping service scan"
        start-stop-daemon --stop --exec /usr/bin/svscan \
                --pidfile /var/run/svscan.pid
        eend $?
        ebegin "Stopping service scan services"
        svc -dx /service/* 2>/dev/null
        eend $?
        ebegin "Stopping service scan logging"
        svc -dx /service/*/log 2>/dev/null
        eend $?
}

------- Comment #1 From Jakub Moc (RETIRED) 2007-12-09 09:37:07 0000 -------
No idea what installs /etc/init.d/svscan; reopen with exact ebuild name and
version.

------- Comment #2 From Tavin Cole 2007-12-09 09:47:44 0000 -------
sys-process/daemontools-0.76-r5

------- Comment #3 From Benedikt Böhm 2008-04-06 16:53:17 0000 -------
fixed in 0.76-r6