From 7e3465a0226b9db1d271ad6cee869f2dc96b4b5b Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 7 Oct 2012 02:00:13 +0200 Subject: [PATCH] Clear recorded PID of lost service. Many callbacks check their svc->pid to determine SVC_RELOAD or SVC_START, they rely on it to be updated. When a service is lost we must therefore clear its recorded PID before asking the callback what to do. Also, swap comparison in debug code for dumping service arguments ... Signed-off-by: Joachim Nilsson --- svc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/svc.c b/svc.c index d3943d63..4d29b2b1 100644 --- a/svc.c +++ b/svc.c @@ -248,6 +248,10 @@ void svc_monitor(void) continue; _d("Ouch, lost pid %d - %s(%d)", lost, name, svc->pid); + + /* No longer running, update books. */ + svc->pid = 0; + if (sig_stopped()) { _e("Stopped, not respawning killed processes."); break; @@ -337,7 +341,7 @@ int svc_start(svc_t *svc) char arg[MAX_ARG_LEN]; snprintf(arg, sizeof(arg), "%s ", args[i]); - if ((sizeof(buf) - strlen(buf)) < strlen(arg)) + if (strlen(arg) < (sizeof(buf) - strlen(buf))) strcat(buf, arg); } _e("%starting %s: %s", respawn ? "Res" : "S", svc->cmd, buf);