Assert svc condition only when PID file has been created/updated

This patch prevents too early start of services depending on other
services.  E.g, if service B depends on A then we must wait for A to
signal that it is ready before we allow B to start -- in a Finit based
system A does this by creating, or touching (updating mtime), its PID
file.  Services (like A) that support SIGHUP should call utime(), or
utimensat(), on the PID file at the end of their SIGHUP handler.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-04-10 19:14:48 +02:00
1 parent cef4b5761a
commit 4ae5c54f45
3 files changed
+22 -4

No files matched your search

+6
View File
@@ -151,6 +151,9 @@ static int service_start(svc_t *svc)
return result;
}
/* Declare we're waiting for svc to create its pidfile */
svc_starting(svc);
/* Block sigchild while forking. */
sigemptyset(&nmask);
sigaddset(&nmask, SIGCHLD);
@@ -329,6 +332,9 @@ static int service_restart(svc_t *svc)
if (verbose)
print_desc("Restarting ", svc->desc);
/* Declare we're waiting for svc to re-assert/touch its pidfile */
svc_starting(svc);
_d("Sending SIGHUP to PID %d", svc->pid);
err = kill(svc->pid, SIGHUP);