From 2155537e624db16a387f7185d32a0ac94ca1ac35 Mon Sep 17 00:00:00 2001 From: Michel-FK Date: Sat, 19 Jun 2021 12:03:58 +0200 Subject: [PATCH] use pid script wherever possible Signed-off-by: Michel-FK --- .../funkey/rootfs-overlay/usr/local/sbin/assembly_tests | 4 ++-- .../board/funkey/rootfs-overlay/usr/local/sbin/powerdown | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests index 81b9a1b..4a67fd5 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/assembly_tests @@ -18,7 +18,7 @@ touch ${LOCK_FILE} ## Register ourself as the running FunKey task for receiving USR1 ## signal for shutting down -echo $$ > "/var/run/funkey.pid" +pid record $$ ## Binaries 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 ## signal for shutting down - echo $$ > "/var/run/funkey.pid" + pid record $$ # check magnet test result if [[ "$res" == "0" ]]; then diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown index 8717ad2..4412a84 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown @@ -4,7 +4,6 @@ #set -x SELF="$(basename ${0})" -PID_FILE="/var/run/funkey.pid" PID_PATH="/var/run/pid_path" REBOOTING_FILE="/run/rebooting" @@ -19,12 +18,12 @@ schedule_powerdown() { # Save current pid path before closing bin # (won't work if bin is already closed) - pid_path=$(dirname $(readlink /proc/$(pid print)/exe)) - echo -n "$pid_path" > "$PID_PATH" + local pid_path=$(dirname $(readlink /proc/$(pid print)/exe)) + echo -n "${pid_path}" > "${PID_PATH}" # Send USR1 signal to the running FunKey process to warn about # 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. # If the signal is caught, then it means the running FunKey