summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2011-05-17 09:35:57 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-18 14:32:45 +0100
commit0424560e5fb00ad5e455af82425143d87a37bcc7 (patch)
tree2f01d74e627985498413a4ec6ec15fa36b41fd76 /meta
parent0b175c42d712103e4149d5580c11e1b0d59220ae (diff)
downloadast2050-yocto-poky-0424560e5fb00ad5e455af82425143d87a37bcc7.zip
ast2050-yocto-poky-0424560e5fb00ad5e455af82425143d87a37bcc7.tar.gz
Add pidofproc to ${sysconfdir}/init.d/functions
Add pidofproc to ${sysconfdir}/init.d/functions, this is used for getting the pid of the process. It uses pidof to implement currently, it may also use the pidfile or ps to implement in the future. (From OE-Core rev: 114a11628fb04c30cc96c9fd23db7a7fbc4fd02e) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-core/initscripts/initscripts-1.0/functions32
1 files changed, 30 insertions, 2 deletions
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/functions b/meta/recipes-core/initscripts/initscripts-1.0/functions
index ac99e11..c1eac3e 100644
--- a/meta/recipes-core/initscripts/initscripts-1.0/functions
+++ b/meta/recipes-core/initscripts/initscripts-1.0/functions
@@ -3,6 +3,35 @@
# functions This file contains functions to be used by most or all
# shell scripts in the /etc/init.d directory.
#
+# NOTE: The pidofproc () doesn't support the process which is a script unless
+# the pidof supports "-x" option. If you want to use it for such a
+# process:
+# 1) If there is no "pidof -x", replace the "pidof $1" with another
+# command like(for core-image-minimal):
+# ps | awk '/'"$1"'/ {print $1}'
+# Or
+# 2) If there is "pidof -x", replace "pidof" with "pidof -x".
+#
+# pidofproc - print the pid of a process
+# $1: the name of the process
+pidofproc () {
+
+ # pidof output null when no program is running, so no "2>/dev/null".
+ pid=`pidof $1`
+ case $? in
+ 0)
+ echo $pid
+ return 0
+ ;;
+ 127)
+ echo "ERROR: command pidof not found" >&2
+ exit 127
+ ;;
+ *)
+ return $?
+ ;;
+ esac
+}
machine_id() { # return the machine ID
awk 'BEGIN { FS=": " } /Hardware/ \
@@ -10,6 +39,5 @@ machine_id() { # return the machine ID
}
killproc() { # kill the named process(es)
- pid=`/bin/pidof $1`
- [ "$pid" != "" ] && kill $pid
+ pid=`pidofproc $1` && kill $pid
}
OpenPOWER on IntegriCloud