We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a5b0402 commit 3b1e0ceCopy full SHA for 3b1e0ce
2 files changed
rewatch/tests/lock.sh
@@ -90,3 +90,5 @@ else
90
cat rewatch.log
91
exit 1
92
fi
93
+
94
+exit_watcher
rewatch/tests/utils.sh
@@ -51,8 +51,29 @@ replace() {
51
52
}
53
54
+wait_for_pid_gone() {
55
+ local pid="$1"; local timeout="${2:-10}"
56
+ while kill -0 "$pid" 2> /dev/null && [ "$timeout" -gt 0 ]; do
57
+ sleep 1
58
+ timeout=$((timeout - 1))
59
+ done
60
+ ! kill -0 "$pid" 2> /dev/null
61
+}
62
63
exit_watcher() {
64
+ local watcher_pid=""
65
+ if [ -f lib/watch.lock ]; then
66
+ watcher_pid=$(cat lib/watch.lock)
67
+ fi
68
69
rm -f lib/watch.lock
70
71
+ if [ -n "$watcher_pid" ]; then
72
+ if ! wait_for_pid_gone "$watcher_pid" 10; then
73
+ error "Watcher process $watcher_pid did not exit after watch.lock was removed"
74
+ return 1
75
76
77
78
79
clear_locks() {
0 commit comments