summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2025-05-30 12:19:11 -0400
committerTavian Barnes <tavianator@tavianator.com>2025-05-30 13:06:10 -0400
commita0fe051f8b2bcc919d67f822b674cdfe8cf1274b (patch)
tree3dec473f016eeddf4470056b50207c2e75facc17
parent79e86eb3baddb9502abf907a80383d810487602f (diff)
downloadbfs-a0fe051f8b2bcc919d67f822b674cdfe8cf1274b.tar.xz
tests/util: Wrap wait EINTR loop into a helperHEADmain
-rw-r--r--tests/posix/exec_sigmask.sh2
-rw-r--r--tests/run.sh7
-rw-r--r--tests/util.sh13
3 files changed, 16 insertions, 6 deletions
diff --git a/tests/posix/exec_sigmask.sh b/tests/posix/exec_sigmask.sh
index 4f2c6c9..2907458 100644
--- a/tests/posix/exec_sigmask.sh
+++ b/tests/posix/exec_sigmask.sh
@@ -13,4 +13,4 @@ mkfifo p1 p2
# Write the `sh` PID to p1, then hang reading p2 until we're killed
! invoke_bfs p1 -exec bash -c 'echo $$ >p1 && read -r _ <p2' bash {} + || fail
-wait
+_wait
diff --git a/tests/run.sh b/tests/run.sh
index 8d3a5d2..3ed2a9c 100644
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -96,16 +96,13 @@ reap_test() {
wait_test() {
local pid line ret
- while true; do
+ while :; do
line=$((LINENO + 1))
- wait -n -ppid
+ _wait -n -ppid
ret=$?
if [ "${pid:-}" ]; then
break
- elif ((ret > 128)); then
- # Interrupted by signal
- continue
else
debug "${BASH_SOURCE[0]}" $line "${RED}error $ret${RST}" >&$DUPERR
exit 1
diff --git a/tests/util.sh b/tests/util.sh
index 4bdb86f..e3eca60 100644
--- a/tests/util.sh
+++ b/tests/util.sh
@@ -202,3 +202,16 @@ nproc() {
|| echo 1
} 2>/dev/null
}
+
+# Run wait, looping if interrupted
+_wait() {
+ local ret=130
+
+ # "If wait is interrupted by a signal, the return status will be greater than 128"
+ while ((ret > 128)); do
+ ret=0
+ wait "$@" || ret=$?
+ done
+
+ return $ret
+}