mirror of
https://git.yoctoproject.org/poky
synced 2026-02-08 01:36:38 +01:00
Fixes bug [YOCTO #1165] The /etc/init.d/skeleton doesn't work on minimal image, this is because of the pidofproc doesn't return "$?" correctly, so store $? in the variable status would fix it. (From OE-Core rev: 4d31193a6969df25bb85a9862b7295e85dcec04b) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
1.1 KiB
1.1 KiB
--Shell-script--
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`
status=$?
case $status in
0)
echo $pid
return 0
;;
127)
echo "ERROR: command pidof not found" >&2
exit 127
;;
*)
return $status
;;
esac
}
machine_id() { # return the machine ID
awk 'BEGIN { FS=": " } /Hardware/
{ gsub(" ", "_", $2); print tolower($2) } ' </proc/cpuinfo
}
killproc() { # kill the named process(es)
pid=pidofproc $1 && kill $pid
}