Revert "Avoid auto-killing tagged app instances in reload script"
This reverts commit fac3b12eb7.
This commit is contained in:
parent
fac3b12eb7
commit
e5aa6f6de7
1 changed files with 18 additions and 22 deletions
|
|
@ -327,28 +327,24 @@ else
|
|||
fi
|
||||
osascript -e "tell application id \"${BUNDLE_ID}\" to activate" || true
|
||||
|
||||
# Safety: keep a single untagged instance, but do not auto-kill tagged runs.
|
||||
# Tagged runs are intentionally parallel/isolated and can look like "launch then close"
|
||||
# if we aggressively prune processes right after `open`.
|
||||
if [[ -z "$TAG" ]]; then
|
||||
sleep 0.2
|
||||
PIDS=($(pgrep -f "${APP_PATH}/Contents/MacOS/" || true))
|
||||
if [[ "${#PIDS[@]}" -gt 1 ]]; then
|
||||
NEWEST_PID=""
|
||||
NEWEST_AGE=999999
|
||||
for PID in "${PIDS[@]}"; do
|
||||
AGE="$(ps -o etimes= -p "$PID" | tr -d ' ')"
|
||||
if [[ -n "$AGE" && "$AGE" -lt "$NEWEST_AGE" ]]; then
|
||||
NEWEST_AGE="$AGE"
|
||||
NEWEST_PID="$PID"
|
||||
fi
|
||||
done
|
||||
for PID in "${PIDS[@]}"; do
|
||||
if [[ "$PID" != "$NEWEST_PID" ]]; then
|
||||
kill "$PID" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
fi
|
||||
# Safety: ensure only one instance is running.
|
||||
sleep 0.2
|
||||
PIDS=($(pgrep -f "${APP_PATH}/Contents/MacOS/" || true))
|
||||
if [[ "${#PIDS[@]}" -gt 1 ]]; then
|
||||
NEWEST_PID=""
|
||||
NEWEST_AGE=999999
|
||||
for PID in "${PIDS[@]}"; do
|
||||
AGE="$(ps -o etimes= -p "$PID" | tr -d ' ')"
|
||||
if [[ -n "$AGE" && "$AGE" -lt "$NEWEST_AGE" ]]; then
|
||||
NEWEST_AGE="$AGE"
|
||||
NEWEST_PID="$PID"
|
||||
fi
|
||||
done
|
||||
for PID in "${PIDS[@]}"; do
|
||||
if [[ "$PID" != "$NEWEST_PID" ]]; then
|
||||
kill "$PID" 2>/dev/null || true
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ -n "${TAG_SLUG:-}" ]]; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue