Browse Source

use pid script wherever possible

Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
Michel-FK 2 years ago
parent
commit
2155537e62

+ 2 - 2
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

+ 3 - 4
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