wechat_ai/wechat_vision/stop_wechat_window_live.sh

23 lines
517 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
PID_FILE="ouptsw/wechat_window_live.pid"
if [[ ! -f "$PID_FILE" ]]; then
printf 'WeChat window live stream is not running: missing %s\n' "$PID_FILE"
exit 0
fi
PID="$(cat "$PID_FILE")"
if [[ -z "$PID" ]] || ! kill -0 "$PID" 2>/dev/null; then
rm -f "$PID_FILE"
printf 'WeChat window live stream is not running. Removed stale pid file.\n'
exit 0
fi
kill "$PID"
sleep 1
rm -f "$PID_FILE"
printf 'WeChat window live stream stopped: pid=%s\n' "$PID"