saving PID_PATH during "pid record" calls, not during powerdown anymore

This commit is contained in:
Vincent-FK 2021-06-19 23:57:10 +02:00
parent 0f174bd18e
commit 977a7f48db
3 changed files with 14 additions and 12 deletions

View File

@ -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

View File

@ -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() {

View File

@ -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