mirror of
https://github.com/troglobit/finit.git
synced 2026-11-19 19:40:50 +00:00
Audit ad2bafb: cleanup of stale pid files
Make sure to check return value of remove(), it may actually signal something useful. Log useful errors. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
00e5a8f5d9
commit
33ccff7733
1 file changed
+5
-2
@@ -674,9 +674,12 @@ void service_monitor(pid_t lost)
|
|||||||
|
|
||||||
_d("collected %s(%d)", svc->cmd, lost);
|
_d("collected %s(%d)", svc->cmd, lost);
|
||||||
|
|
||||||
/* Remove pid file (in case service is careless) */
|
/* Try removing PID file (in case service does not clean up after itself) */
|
||||||
snprintf(pidfile, sizeof(pidfile), "%s%s.pid", _PATH_VARRUN, basename(svc->cmd));
|
snprintf(pidfile, sizeof(pidfile), "%s%s.pid", _PATH_VARRUN, basename(svc->cmd));
|
||||||
remove(pidfile);
|
if (remove(pidfile)) {
|
||||||
|
if (errno != ENOENT)
|
||||||
|
FLOG_PERROR("Failed removing service %s pidfile %s", basename(svc->cmd), pidfile);
|
||||||
|
}
|
||||||
|
|
||||||
/* No longer running, update books. */
|
/* No longer running, update books. */
|
||||||
svc->pid = 0;
|
svc->pid = 0;
|
||||||
|
|||||||
Reference in new issue
Block a user