tools: start leaves a shell it didn't start alone

the user may run amane from a terminal; start used to crash into it with
'amane is already running'. now it says which pid runs and stops
This commit is contained in:
server2
2026-10-08 01:37:10 +02:00
parent 9d6a13f876
commit ddaef1f805
+3
View File
@@ -55,6 +55,9 @@ start)
# the old shell can take a few seconds to let go of amane's socket; wait for it, or the new one panics
remote 'test -f shell.pid && kill $(cat shell.pid) 2>/dev/null
for i in $(seq 50); do pgrep -F shell.pid > /dev/null 2>&1 || break; sleep 0.1; done
# a shell this script did not start belongs to the user: leave it, and say so
other=$(pgrep -x amane-shell)
if [ -n "$other" ]; then echo "not started: another amane-shell runs (pid $other), not started by this script"; exit 1; fi
binary=~/.cache/amane/amane-shell
test -x "$binary" || binary=~/.cache/amane/project/target/debug/amane-shell
AMANE_FRAMES=1 setsid -f sh -c "echo \$\$ > shell.pid; exec $binary" > shell.log 2>&1