From c64a71ff301e3c95e6e11415b9536cd837fadfe6 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 23 Jan 2018 00:17:02 +0100 Subject: [PATCH] Follow-up to ba2ab4b, crashing services may not have a PID rn - Don't warn of missing PID, even if only _d(), perfectly normal - Allow stopping restart timer of non-services (e.g. task/run) - Allow stopping services with no PID rn, i.e. stop libuEv timer Signed-off-by: Joachim Nilsson --- src/service.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/service.c b/src/service.c index 0c155e0e..dd5a17ca 100644 --- a/src/service.c +++ b/src/service.c @@ -436,13 +436,8 @@ static int service_stop(svc_t *svc) #endif service_timeout_cancel(svc); - if (svc->pid <= 1) { - _d("Bad PID %d for %s, SIGTERM", svc->pid, svc->cmd); + if (svc->pid <= 1) return 1; - } - - if (SVC_TYPE_SERVICE != svc->type) - return 0; _d("Sending SIGTERM to pid:%d name:%s", svc->pid, pid_get_name(svc->pid, NULL, 0)); svc_set_state(svc, SVC_STOPPING_STATE); @@ -858,12 +853,10 @@ void service_unregister(svc_t *svc) return; /* - * Only call service_stop() if @svc is still running *and* it's - * not an inetd connection. This prevents infinite recursion if - * called from service_step(), or if it's an inet connection and - * it's already been stopped. + * Only try stopping @svc if it's *not* an inetd connection. + * Prevents infinite recursion when called from service_step() */ - if (svc->pid && !svc_is_inetd_conn(svc)) + if (!svc_is_inetd_conn(svc)) service_stop(svc); if (svc_is_inetd(svc)) {