Skip to content

Commit 977a7f4

Browse files
committed
saving PID_PATH during "pid record" calls, not during powerdown anymore
1 parent 0f174bd commit 977a7f4

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

FunKey/board/funkey/rootfs-overlay/usr/local/sbin/instant_play

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ save)
6464
fi
6565
shift
6666

67-
# Write quick load file args
68-
echo -n "" > "${INSTANT_PLAY_FILE}"
69-
printf "'" >> "${INSTANT_PLAY_FILE}"
70-
# First arg is prog name, forcing real path
67+
# Get curent binary real path
7168
bin=$(printf %s "$1" | sed "s/'/'\\\\''/g")
7269
bin_name=$(basename "$bin")
7370
bin_path="$(cat $PID_PATH)"/"$bin_name"
71+
72+
# Write quick load file args
73+
echo -n "" > "${INSTANT_PLAY_FILE}"
74+
printf "'" >> "${INSTANT_PLAY_FILE}"
7475
echo -n "$bin_path" >> "${INSTANT_PLAY_FILE}"
7576
printf "' " >> "${INSTANT_PLAY_FILE}"
7677
shift

FunKey/board/funkey/rootfs-overlay/usr/local/sbin/pid

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
SELF="$(basename ${0})"
77
PID_FILE="/var/run/funkey.pid"
8+
PID_PATH="/var/run/pid_path"
89

910
usage() {
1011
>&2 echo "Usage: ${SELF} record pid"
@@ -16,10 +17,16 @@ usage() {
1617
record_pid() {
1718
local pid="${1}"
1819
if ! [ ! "${pid}" -ne "${pid}" ]; then
19-
>&2 echo "error: ${pid} is not a number"
20-
exit 2
20+
>&2 echo "error: ${pid} is not a number"
21+
exit 2
2122
fi
23+
24+
# Save PID
2225
echo "${1}" > "${PID_FILE}"
26+
27+
# Save current pid path
28+
pid_path=$(dirname $(readlink /proc/${pid}/exe))
29+
echo -n "$pid_path" > "$PID_PATH"
2330
}
2431

2532
erase_pid() {

FunKey/board/funkey/rootfs-overlay/usr/local/sbin/powerdown

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
SELF="$(basename ${0})"
77
PID_FILE="/var/run/funkey.pid"
8-
PID_PATH="/var/run/pid_path"
98
REBOOTING_FILE="/run/rebooting"
109

1110
usage() {
@@ -17,11 +16,6 @@ usage() {
1716

1817
schedule_powerdown() {
1918

20-
# Save current pid path before closing bin
21-
# (won't work if bin is already closed)
22-
pid_path=$(dirname $(readlink /proc/$(pid print)/exe))
23-
echo -n "$pid_path" > "$PID_PATH"
24-
2519
# Send USR1 signal to the running FunKey process to warn about
2620
# impending shutdown
2721
pkill -USR1 -F "${PID_FILE}" > /dev/null 2>&1

0 commit comments

Comments
 (0)