Patchwork [10/11] initscripts: Add status function to /etc/init.d/functions

login
register
mail settings
Submitter Mark Hatle
Date Feb. 7, 2013, 11:59 p.m.
Message ID <0915cf90c30fa1edf3b84d97915f50fe6b88c2f7.1360270256.git.mark.hatle@windriver.com>
Download mbox | patch
Permalink /patch/44295/
State Accepted
Commit 2e913bc62abd9a5a1373bc9f0fbce68c0838cbdf
Headers show

Comments

Mark Hatle - Feb. 7, 2013, 11:59 p.m.
From: Jesse Zhang <sen.zhang@windriver.com>

[ CQID: WIND00388860 ]

Many initscripts want a simple way to display status information.
Add the 'status' function to the functions file.

Signed-off-by: Jesse Zhang <sen.zhang@windriver.com>
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
 meta/recipes-core/initscripts/initscripts-1.0/functions | 15 +++++++++++++++
 meta/recipes-core/initscripts/initscripts_1.0.bb        |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)

Patch

diff --git a/meta/recipes-core/initscripts/initscripts-1.0/functions b/meta/recipes-core/initscripts/initscripts-1.0/functions
index dd7da2b..944e3a5 100644
--- a/meta/recipes-core/initscripts/initscripts-1.0/functions
+++ b/meta/recipes-core/initscripts/initscripts-1.0/functions
@@ -42,3 +42,18 @@  machine_id() { # return the machine ID
 killproc() { # kill the named process(es)
 	pid=`pidofproc $1` && kill $pid
 }
+
+status() {
+    local pid
+    if [ "$#" = 0 ]; then
+        echo "Usage: status {program}"
+        return 1
+    fi
+    pid=`pidofproc $1`
+    if [ -n "$pid" ]; then
+        echo "$1 (pid $pid) is running..."
+    else
+        echo "$1 is stopped"
+    fi
+    return 3
+}
diff --git a/meta/recipes-core/initscripts/initscripts_1.0.bb b/meta/recipes-core/initscripts/initscripts_1.0.bb
index 68f8034..649e182 100644
--- a/meta/recipes-core/initscripts/initscripts_1.0.bb
+++ b/meta/recipes-core/initscripts/initscripts_1.0.bb
@@ -3,7 +3,7 @@  DESCRIPTION = "Initscripts provide the basic system startup initialization scrip
 SECTION = "base"
 LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"
-PR = "r139"
+PR = "r140"
 
 INHIBIT_DEFAULT_DEPS = "1"