Follow-up to d82d1197: ensure PID file doesn't exist

Before we clear all conditions for a service, ensure pid_file_read()
didn't fail due to the PID file not (yet) containing a valid number.

If the process dies while starting up, and subsequently removes its
PID file, then the file shouldn't exist.  However, if we get inotify
before the process has finished writing the PID, then we just return
and wait for the next event.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2022-10-16 20:01:29 +02:00
parent e177b866a9
commit 488e6c2adf
+4 -2
View File
@@ -92,9 +92,11 @@ static void pidfile_update_conds(char *dir, char *name, uint32_t mask)
if (svc_is_forking(svc)) {
pid_t pid;
pid = pid_file_read(pid_file(svc));
pid = pid_file_read(fn);
if (pid == -1) {
cond_clear(cond);
/* handle case when service dies immediately */
if (!fexist(fn))
cond_clear(cond);
return;
}