diff options
author | Xiao Pan <gky44px1999@gmail.com> | 2024-05-05 20:19:04 -0700 |
---|---|---|
committer | Xiao Pan <gky44px1999@gmail.com> | 2024-05-05 20:19:04 -0700 |
commit | edb37abc9eda004a960e3e792b5b4be3d403a7e9 (patch) | |
tree | 78afedadc90e4009a51cf335557a3051f4d23378 /sh/dyafk | |
parent | 103766cfc724c9e10161f049862a5800980a4822 (diff) |
dyafk killall firefox pid cause ungracefully poweroff and prompt warning cause not actually open url, kill only parent process maybe can fix
Diffstat (limited to 'sh/dyafk')
-rwxr-xr-x | sh/dyafk | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -8,11 +8,17 @@ while :; do if [ "$(curl -s https://www.douyu.com/betard/9640128 | jq '.room.show_status')" -eq 1 ]; then if ! pidof -q firefox; then firefox --headless --profile "$HOME/.mozilla/firefox/dyafk" https://www.douyu.com/9640128 & + # assign previous background process to pid variable + pid=$! fi else - if pidof -q firefox; then - kill $(pidof firefox) 2>/dev/null - # for logging, so I know when firefox killed, which also need that `if pidof -q firefox` + if [ "$pid" ]; then + # seems need to only SIGTERM kill the parent firefox process, else firefox will prompt me firefox closed unexpectedly warning which cause firefox not actually open the url + # https://www.reddit.com/r/firefox/comments/fq1mhi/kill_firefox_gracefully_via_terminal_headless/ + # firefox seems now can handle SIGTERM on linux? https://bugzilla.mozilla.org/show_bug.cgi?id=1837907 + kill "$pid" + pid= + # for logging, I want to know when firefox killed echo 'kill firefox' fi fi |