From 33ccff7733e0c0b10c74727879708c6b5a364d7c Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sat, 4 Jun 2016 21:46:25 +0200 Subject: [PATCH] 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 --- service.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/service.c b/service.c index 99da10fe..e17f6267 100755 --- a/service.c +++ b/service.c @@ -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;