From 977a7f48db0cac91d53f2032aada49d10cb8b1a0 Mon Sep 17 00:00:00 2001 From: Vincent-FK Date: Sat, 19 Jun 2021 23:57:10 +0200 Subject: [PATCH] saving PID_PATH during "pid record" calls, not during powerdown anymore --- .../funkey/rootfs-overlay/usr/local/sbin/instant_play | 9 +++++---- FunKey/board/funkey/rootfs-overlay/usr/local/sbin/pid | 11 +++++++++-- .../funkey/rootfs-overlay/usr/local/sbin/powerdown | 6 ------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play index 43a5b4e..c7c8dda 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play @@ -64,13 +64,14 @@ save) fi shift - # Write quick load file args - echo -n "" > "${INSTANT_PLAY_FILE}" - printf "'" >> "${INSTANT_PLAY_FILE}" - # First arg is prog name, forcing real path + # Get curent binary real path bin=$(printf %s "$1" | sed "s/'/'\\\\''/g") bin_name=$(basename "$bin") bin_path="$(cat $PID_PATH)"/"$bin_name" + + # Write quick load file args + echo -n "" > "${INSTANT_PLAY_FILE}" + printf "'" >> "${INSTANT_PLAY_FILE}" echo -n "$bin_path" >> "${INSTANT_PLAY_FILE}" printf "' " >> "${INSTANT_PLAY_FILE}" shift diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/pid b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/pid index 19fca61..e444720 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/pid +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/pid @@ -5,6 +5,7 @@ SELF="$(basename ${0})" PID_FILE="/var/run/funkey.pid" +PID_PATH="/var/run/pid_path" usage() { >&2 echo "Usage: ${SELF} record pid" @@ -16,10 +17,16 @@ usage() { record_pid() { local pid="${1}" if ! [ ! "${pid}" -ne "${pid}" ]; then - >&2 echo "error: ${pid} is not a number" - exit 2 + >&2 echo "error: ${pid} is not a number" + exit 2 fi + + # Save PID echo "${1}" > "${PID_FILE}" + + # Save current pid path + pid_path=$(dirname $(readlink /proc/${pid}/exe)) + echo -n "$pid_path" > "$PID_PATH" } erase_pid() { diff --git a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown index 8717ad2..067fc8a 100755 --- a/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown +++ b/FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown @@ -5,7 +5,6 @@ SELF="$(basename ${0})" PID_FILE="/var/run/funkey.pid" -PID_PATH="/var/run/pid_path" REBOOTING_FILE="/run/rebooting" usage() { @@ -17,11 +16,6 @@ usage() { 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" - # Send USR1 signal to the running FunKey process to warn about # impending shutdown pkill -USR1 -F "${PID_FILE}" > /dev/null 2>&1