From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 20A7A1396D0 for ; Mon, 18 Sep 2017 18:07:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7129D1FC0C8; Mon, 18 Sep 2017 18:07:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 52A851FC0C8 for ; Mon, 18 Sep 2017 18:07:42 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8E15433BE25 for ; Mon, 18 Sep 2017 18:07:41 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0E2CA908A for ; Mon, 18 Sep 2017 18:07:39 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1505755537.3cf19b0f30a90157d23d09ded304439f1eb42d4a.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/supervise-daemon.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 3cf19b0f30a90157d23d09ded304439f1eb42d4a X-VCS-Branch: master Date: Mon, 18 Sep 2017 18:07:39 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 09d220c9-66f8-44bb-9776-db6653d5745d X-Archives-Hash: 80bdeede0b9bcdab393c60ff60c16b3b commit: 3cf19b0f30a90157d23d09ded304439f1eb42d4a Author: William Hubbs gmail com> AuthorDate: Mon Sep 18 17:25:37 2017 +0000 Commit: William Hubbs gentoo org> CommitDate: Mon Sep 18 17:25:37 2017 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3cf19b0f supervise-daemon: code cleanup Clean up the process for killing an active supervisor when stopping. src/rc/supervise-daemon.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 7b894e7b..2800d1a2 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -432,6 +432,7 @@ int main(int argc, char **argv) int respawn_period = 5; time_t respawn_now= 0; time_t first_spawn= 0; + struct timespec ts; struct passwd *pw; struct group *gr; FILE *fp; @@ -658,17 +659,18 @@ int main(int argc, char **argv) if (stop) { pid = get_pid(applet, pidfile); - if (pid == -1) - i = pid; - else + if (pid != -1) { i = kill(pid, SIGTERM); - if (i != 0) - /* We failed to send the signal */ - exit(EXIT_FAILURE); - - /* wait for the supervisor to go down */ - while (kill(pid, 0) == 0) - sleep(1); + if (i != 0) + /* We failed to send the signal */ + exit(EXIT_FAILURE); + + /* wait for the supervisor to go down */ + while (kill(pid, 0) == 0) + ts.tv_sec = 0; + ts.tv_nsec = 1; + nanosleep(&ts, NULL); + } /* Even if we have not actually killed anything, we should * remove information about it as it may have unexpectedly