use pid script wherever possible

Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
Michel-FK 2021-06-19 12:03:58 +02:00
parent 04570f0499
commit 2155537e62
2 changed files with 5 additions and 6 deletions

View File

@ -18,7 +18,7 @@ touch ${LOCK_FILE}
## Register ourself as the running FunKey task for receiving USR1 ## Register ourself as the running FunKey task for receiving USR1
## signal for shutting down ## signal for shutting down
echo $$ > "/var/run/funkey.pid" pid record $$
## Binaries ## Binaries
PROD_SCREEN_BIN="/usr/local/sbin/funkey_prod_screens" PROD_SCREEN_BIN="/usr/local/sbin/funkey_prod_screens"
@ -224,7 +224,7 @@ function launch_tests_up_until_magnet {
## Register ourself back as the running FunKey task for receiving USR1 ## Register ourself back as the running FunKey task for receiving USR1
## signal for shutting down ## signal for shutting down
echo $$ > "/var/run/funkey.pid" pid record $$
# check magnet test result # check magnet test result
if [[ "$res" == "0" ]]; then if [[ "$res" == "0" ]]; then

View File

@ -4,7 +4,6 @@
#set -x #set -x
SELF="$(basename ${0})" SELF="$(basename ${0})"
PID_FILE="/var/run/funkey.pid"
PID_PATH="/var/run/pid_path" PID_PATH="/var/run/pid_path"
REBOOTING_FILE="/run/rebooting" REBOOTING_FILE="/run/rebooting"
@ -19,12 +18,12 @@ schedule_powerdown() {
# Save current pid path before closing bin # Save current pid path before closing bin
# (won't work if bin is already closed) # (won't work if bin is already closed)
pid_path=$(dirname $(readlink /proc/$(pid print)/exe)) local pid_path=$(dirname $(readlink /proc/$(pid print)/exe))
echo -n "$pid_path" > "$PID_PATH" echo -n "${pid_path}" > "${PID_PATH}"
# Send USR1 signal to the running FunKey process to warn about # Send USR1 signal to the running FunKey process to warn about
# impending shutdown # impending shutdown
pkill -USR1 -F "${PID_FILE}" > /dev/null 2>&1 pkill -USR1 "$(pid print)" > /dev/null 2>&1
# Delay for the given grace period seconds to catch signal USR2. # Delay for the given grace period seconds to catch signal USR2.
# If the signal is caught, then it means the running FunKey # If the signal is caught, then it means the running FunKey