diff options
Diffstat (limited to 'meta')
-rw-r--r-- | meta/recipes-core/initscripts/initscripts-1.0/functions | 32 |
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 ac99e112c7..c1eac3efda 100644 --- a/meta/recipes-core/initscripts/initscripts-1.0/functions +++ b/meta/recipes-core/initscripts/initscripts-1.0/functions | |||
@@ -3,6 +3,35 @@ | |||
3 | # functions This file contains functions to be used by most or all | 3 | # functions This file contains functions to be used by most or all |
4 | # shell scripts in the /etc/init.d directory. | 4 | # shell scripts in the /etc/init.d directory. |
5 | # | 5 | # |
6 | # NOTE: The pidofproc () doesn't support the process which is a script unless | ||
7 | # the pidof supports "-x" option. If you want to use it for such a | ||
8 | # process: | ||
9 | # 1) If there is no "pidof -x", replace the "pidof $1" with another | ||
10 | # command like(for core-image-minimal): | ||
11 | # ps | awk '/'"$1"'/ {print $1}' | ||
12 | # Or | ||
13 | # 2) If there is "pidof -x", replace "pidof" with "pidof -x". | ||
14 | # | ||
15 | # pidofproc - print the pid of a process | ||
16 | # $1: the name of the process | ||
17 | pidofproc () { | ||
18 | |||
19 | # pidof output null when no program is running, so no "2>/dev/null". | ||
20 | pid=`pidof $1` | ||
21 | case $? in | ||
22 | 0) | ||
23 | echo $pid | ||
24 | return 0 | ||
25 | ;; | ||
26 | 127) | ||
27 | echo "ERROR: command pidof not found" >&2 | ||
28 | exit 127 | ||
29 | ;; | ||
30 | *) | ||
31 | return $? | ||
32 | ;; | ||
33 | esac | ||
34 | } | ||
6 | 35 | ||
7 | machine_id() { # return the machine ID | 36 | machine_id() { # return the machine ID |
8 | awk 'BEGIN { FS=": " } /Hardware/ \ | 37 | awk 'BEGIN { FS=": " } /Hardware/ \ |
@@ -10,6 +39,5 @@ machine_id() { # return the machine ID | |||
10 | } | 39 | } |
11 | 40 | ||
12 | killproc() { # kill the named process(es) | 41 | killproc() { # kill the named process(es) |
13 | pid=`/bin/pidof $1` | 42 | pid=`pidofproc $1` && kill $pid |
14 | [ "$pid" != "" ] && kill $pid | ||
15 | } | 43 | } |