We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2d5a000 commit dee432cCopy full SHA for dee432c
2 files changed
rewatch/tests/lock/01-lock-when-watching.sh
@@ -92,3 +92,5 @@ else
92
cat rewatch.log
93
exit 1
94
fi
95
+
96
+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