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 E3B10139694 for ; Fri, 12 May 2017 02:42:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 094C0E0CBC; Fri, 12 May 2017 02:42:49 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D9335E0CBC for ; Fri, 12 May 2017 02:42:48 +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 CEB9D3416A1 for ; Fri, 12 May 2017 02:42:47 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 445527439 for ; Fri, 12 May 2017 02:42:46 +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: <1494528860.a3250e77d412f2290e381b9e7569930d95e4fc5b.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: a3250e77d412f2290e381b9e7569930d95e4fc5b X-VCS-Branch: master Date: Fri, 12 May 2017 02:42:46 +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: 75a3e35d-4fb4-456f-ac3c-e53dc3269927 X-Archives-Hash: 6c89d78b471d94b04d7776c286d91630 commit: a3250e77d412f2290e381b9e7569930d95e4fc5b Author: William Hubbs gmail com> AuthorDate: Thu May 11 18:52:22 2017 +0000 Commit: William Hubbs gentoo org> CommitDate: Thu May 11 18:54:20 2017 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=a3250e77 supervise-daemon: save start time and respawn count This will allow rc-status to display an uptime and restart count for supervised processes. src/rc/supervise-daemon.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c index 13aba1a3..bc5fd3d0 100644 --- a/src/rc/supervise-daemon.c +++ b/src/rc/supervise-daemon.c @@ -171,7 +171,8 @@ static pid_t get_pid(const char *pidfile) return pid; } -static void child_process(char *exec, char **argv) +static void child_process(char *exec, char **argv, char *svcname, + int start_count) { RC_STRINGLIST *env_list; RC_STRING *env; @@ -183,6 +184,9 @@ static void child_process(char *exec, char **argv) char *np; char **c; char cmdline[PATH_MAX]; + time_t start_time; + char start_time_string[20]; + char start_count_string[20]; #ifdef HAVE_PAM pam_handle_t *pamh = NULL; @@ -338,6 +342,13 @@ static void child_process(char *exec, char **argv) c++; } syslog(LOG_INFO, "Running command line: %s", cmdline); + if (svcname) { +start_time = time(NULL); +strftime(start_time_string, 20, "%Y-%m-%d %H:%M:%S", localtime(&start_time)); + rc_service_value_set(svcname, "start_time", start_time_string); +sprintf(start_count_string, "%i", start_count); + rc_service_value_set(svcname, "start_count", start_count_string); + } execvp(exec, argv); #ifdef HAVE_PAM @@ -778,7 +789,7 @@ int main(int argc, char **argv) if (child_pid == -1) eerrorx("%s: fork: %s", applet, strerror(errno)); if (child_pid == 0) - child_process(exec, argv); + child_process(exec, argv, svcname, respawn_count); } } @@ -792,5 +803,5 @@ int main(int argc, char **argv) } exit(EXIT_SUCCESS); } else if (child_pid == 0) - child_process(exec, argv); + child_process(exec, argv, svcname, respawn_count); }