services: remove .pid file for (careless) died processes

Signed-off-by: Jonas Johansson <jonas.johansson@westermo.se>
This commit is contained in:
Jonas Johansson
2016-05-20 09:08:38 +02:00
parent c5fad8e659
commit ad2bafbfe8
+5
View File
@@ -600,6 +600,7 @@ void service_unregister(svc_t *svc)
void service_monitor(pid_t lost)
{
svc_t *svc;
char pidfile[MAX_ARG_LEN];
if (fexist(SYNC_SHUTDOWN) || lost <= 1)
return;
@@ -619,6 +620,10 @@ void service_monitor(pid_t lost)
_d("collected %s(%d)", svc->cmd, lost);
/* Remove pid file (in case service is careless) */
snprintf(pidfile, sizeof(pidfile), "%s%s.pid", _PATH_VARRUN, basename(svc->cmd));
remove(pidfile);
/* No longer running, update books. */
svc->pid = 0;
service_step(svc);