saving PID_PATH during "pid record" calls, not during powerdown anymore
This commit is contained in:
parent
0f174bd18e
commit
977a7f48db
|
@ -64,13 +64,14 @@ save)
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
|
|
||||||
# Write quick load file args
|
# Get curent binary real path
|
||||||
echo -n "" > "${INSTANT_PLAY_FILE}"
|
|
||||||
printf "'" >> "${INSTANT_PLAY_FILE}"
|
|
||||||
# First arg is prog name, forcing real path
|
|
||||||
bin=$(printf %s "$1" | sed "s/'/'\\\\''/g")
|
bin=$(printf %s "$1" | sed "s/'/'\\\\''/g")
|
||||||
bin_name=$(basename "$bin")
|
bin_name=$(basename "$bin")
|
||||||
bin_path="$(cat $PID_PATH)"/"$bin_name"
|
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}"
|
echo -n "$bin_path" >> "${INSTANT_PLAY_FILE}"
|
||||||
printf "' " >> "${INSTANT_PLAY_FILE}"
|
printf "' " >> "${INSTANT_PLAY_FILE}"
|
||||||
shift
|
shift
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
SELF="$(basename ${0})"
|
SELF="$(basename ${0})"
|
||||||
PID_FILE="/var/run/funkey.pid"
|
PID_FILE="/var/run/funkey.pid"
|
||||||
|
PID_PATH="/var/run/pid_path"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
>&2 echo "Usage: ${SELF} record pid"
|
>&2 echo "Usage: ${SELF} record pid"
|
||||||
|
@ -16,10 +17,16 @@ usage() {
|
||||||
record_pid() {
|
record_pid() {
|
||||||
local pid="${1}"
|
local pid="${1}"
|
||||||
if ! [ ! "${pid}" -ne "${pid}" ]; then
|
if ! [ ! "${pid}" -ne "${pid}" ]; then
|
||||||
>&2 echo "error: ${pid} is not a number"
|
>&2 echo "error: ${pid} is not a number"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Save PID
|
||||||
echo "${1}" > "${PID_FILE}"
|
echo "${1}" > "${PID_FILE}"
|
||||||
|
|
||||||
|
# Save current pid path
|
||||||
|
pid_path=$(dirname $(readlink /proc/${pid}/exe))
|
||||||
|
echo -n "$pid_path" > "$PID_PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
erase_pid() {
|
erase_pid() {
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
SELF="$(basename ${0})"
|
SELF="$(basename ${0})"
|
||||||
PID_FILE="/var/run/funkey.pid"
|
PID_FILE="/var/run/funkey.pid"
|
||||||
PID_PATH="/var/run/pid_path"
|
|
||||||
REBOOTING_FILE="/run/rebooting"
|
REBOOTING_FILE="/run/rebooting"
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
|
@ -17,11 +16,6 @@ usage() {
|
||||||
|
|
||||||
schedule_powerdown() {
|
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
|
# 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 -F "${PID_FILE}" > /dev/null 2>&1
|
||||||
|
|
Loading…
Reference in New Issue