1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 20:19:45 +00:00

Fix the system update check problem

This commit is contained in:
Tw93
2025-12-04 17:52:19 +08:00
parent 44825732a9
commit 36c993ec1c
4 changed files with 31 additions and 24 deletions

View File

@@ -553,23 +553,23 @@ run_with_timeout() {
"$@" &
local cmd_pid=$!
# More efficient wait: use wait with timeout in subshell
(
sleep "$duration" &
local timer_pid=$!
wait "$cmd_pid" 2>/dev/null && kill "$timer_pid" 2>/dev/null && exit 0
kill -TERM "$cmd_pid" 2>/dev/null || true
wait "$cmd_pid" 2> /dev/null && kill "$timer_pid" 2> /dev/null && exit 0
kill -TERM "$cmd_pid" 2> /dev/null || true
sleep 0.5
kill -KILL "$cmd_pid" 2>/dev/null || true
kill -KILL "$cmd_pid" 2> /dev/null || true
exit 124
) &
local watcher_pid=$!
wait "$cmd_pid" 2>/dev/null
wait "$cmd_pid" 2> /dev/null
local exit_code=$?
kill "$watcher_pid" 2>/dev/null || true
wait "$watcher_pid" 2>/dev/null || true
kill "$watcher_pid" 2> /dev/null || true
wait "$watcher_pid" 2> /dev/null || true
return $exit_code
}