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:
Joachim Nilsson committed 2016-06-04 21:46:25 +02:00
1 parent 00e5a8f5d9
commit 33ccff7733
1 file changed
+5 -2
+5 -2
View File
@@ -674,9 +674,12 @@ void service_monitor(pid_t 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));
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. */
svc->pid = 0;