Skip to content

Commit 0f5d755

Browse files
committed
Don't disrupt dependents on reload of SIGHUP-capable service
This fixes a real bug where `initctl reload syslogd` unconditionally clears syslogd's pid condition, causing all dependent services (dbus, dnsmasq, etc.) to be stopped even though syslogd handles SIGHUP gracefully and its PID/pidfile persist. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent 5bbfe47 commit 0f5d755

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/api.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,22 @@ static int reload(svc_t *svc, void *user_data)
126126

127127
/*
128128
* Clear conditions before reload to ensure dependent services
129-
* are properly updated. The conditions are reasserted when
130-
* the service touches its PID file after processing SIGHUP.
129+
* are properly updated. Only needed when the service does NOT
130+
* support SIGHUP (noreload), because then it will be stopped
131+
* and restarted, so conditions genuinely go away. When the
132+
* service handles SIGHUP, its PID and pidfile persist, so the
133+
* condition stays valid and dependents should not be disrupted.
131134
*
132135
* Note: only clear 'ready' for services where the pidfile
133136
* inotify handler reasserts it (pid/none). For s6/systemd
134137
* services readiness relies on their respective notification
135138
* mechanism which may not re-trigger on SIGHUP.
136139
*/
137-
cond_clear(mkcond(svc, cond, sizeof(cond)));
138-
if (svc->notify == SVC_NOTIFY_PID || svc->notify == SVC_NOTIFY_NONE)
139-
service_ready(svc, 0);
140+
if (svc_is_noreload(svc)) {
141+
cond_clear(mkcond(svc, cond, sizeof(cond)));
142+
if (svc->notify == SVC_NOTIFY_PID || svc->notify == SVC_NOTIFY_NONE)
143+
service_ready(svc, 0);
144+
}
140145

141146
svc_mark_dirty(svc);
142147
service_step(svc);

0 commit comments

Comments
 (0)