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 8C18C1396D9 for ; Thu, 26 Oct 2017 19:02:01 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 070E12BC01A; Thu, 26 Oct 2017 19:02:01 +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 DBCBF2BC01A for ; Thu, 26 Oct 2017 19:02:00 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (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 14A2833BF51 for ; Thu, 26 Oct 2017 19:02:00 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 18EB5834 for ; Thu, 26 Oct 2017 19:01:57 +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: <1509041896.490f855aef581a720c6c0be0d8407fe6d279f9f5.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:0.34.x commit in: src/rc/, sh/ X-VCS-Repository: proj/openrc X-VCS-Files: sh/supervise-daemon.sh src/rc/rc-status.c X-VCS-Directories: src/rc/ sh/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: 490f855aef581a720c6c0be0d8407fe6d279f9f5 X-VCS-Branch: 0.34.x Date: Thu, 26 Oct 2017 19:01:57 +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: 597f9091-6169-4b0f-bd6f-6d7d9cf90a85 X-Archives-Hash: 5055848780d1d45b8df367d259ee76b7 commit: 490f855aef581a720c6c0be0d8407fe6d279f9f5 Author: William Hubbs gmail com> AuthorDate: Thu Oct 26 18:11:12 2017 +0000 Commit: William Hubbs gentoo org> CommitDate: Thu Oct 26 18:18:16 2017 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=490f855a implement "unsupervised" status The unsupervised status is to be used when a supervisor of a supervised service dies but leaves the service daemon itself running. sh/supervise-daemon.sh | 21 +++++---------------- src/rc/rc-status.c | 11 ++++++++++- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/sh/supervise-daemon.sh b/sh/supervise-daemon.sh index d2cfe932..e5d8d461 100644 --- a/sh/supervise-daemon.sh +++ b/sh/supervise-daemon.sh @@ -58,22 +58,11 @@ supervise_stop() _check_supervised() { - [ "$RC_UNAME" != Linux ] && return 0 - local child_pid="$(service_get_value "child_pid")" - local pid="$(cat ${pidfile})" - if [ -n "${child_pid}" ]; then - if ! [ -e "/proc/${pid}" ] && [ -e "/proc/${child_pid}" ]; then - if [ -e "/proc/self/ns/pid" ] && [ -e "/proc/${child_pid}/ns/pid" ]; then - local n1 n2 - n1=$(readlink "/proc/self/ns/pid") - n2=$(readlink "/proc/${child_pid}/ns/pid") - if [ "${n1}" = "${n2}" ]; then - return 1 - fi - else - return 1 - fi - fi + local child_pid start_time + child_pid="$(service_get_value "child_pid")" + start_time="$(service_get_value "start_time")" + if [ -n "${child_pid}" ] && [ -n "${start_time}" ]; then + return 1 fi return 0 } diff --git a/src/rc/rc-status.c b/src/rc/rc-status.c index 9a094d47..d29f876a 100644 --- a/src/rc/rc-status.c +++ b/src/rc/rc-status.c @@ -128,6 +128,8 @@ print_service(const char *service) { char status[60]; char uptime [40]; + char *child_pid = NULL; + char *start_time = NULL; int cols = printf(" %s", service); const char *c = ecolor(ECOLOR_GOOD); RC_SERVICE state = rc_service_state(service); @@ -147,7 +149,14 @@ print_service(const char *service) rc_service_daemons_crashed(service) && errno != EACCES) { - snprintf(status, sizeof(status), " crashed "); + child_pid = rc_service_value_get(service, "child_pid"); + start_time = rc_service_value_get(service, "start_time"); + if (start_time && child_pid) + snprintf(status, sizeof(status), " unsupervised "); + else + snprintf(status, sizeof(status), " crashed "); + free(child_pid); + free(start_time); } else { get_uptime(service, uptime, 40); snprintf(status, sizeof(status), " started %s", uptime);