tests: make process cleanup more robust

* tests/cat/cat-buf.sh: Always call 'wait' in case the process already
exited before being killed.
* tests/cp/existing-perm-race.sh: Likewise.
* tests/cp/file-perm-race.sh: Likewise.
* tests/cp/parent-perm-race.sh: Likewise.
* tests/cp/sparse-to-pipe.sh: Likewise.
* tests/du/move-dir-while-traversing.sh: Likewise.
* tests/help/help-version.sh: Likewise.
* tests/misc/stdbuf.sh: Likewise.
* tests/mv/i-3.sh: Likewise.
* tests/printf/printf-surprise.sh: Likewise.
* tests/rm/isatty.sh: Likewise.
* tests/sort/sort-compress-proc.sh: Likewise.
* tests/sort/sort-spinlock-abuse.sh: Likewise.
* tests/tail/F-headers.sh: Likewise.
* tests/tail/F-vs-missing.sh: Likewise.
* tests/tail/F-vs-rename.sh: Likewise.
* tests/tail/append-only.sh: Likewise.
* tests/tail/assert-2.sh: Likewise.
* tests/tail/assert.sh: Likewise.
* tests/tail/debug.sh: Likewise.
* tests/tail/descriptor-vs-rename.sh: Likewise.
* tests/tail/follow-name.sh: Likewise.
* tests/tail/follow-stdin.sh: Likewise.
* tests/tail/follow-symlink.sh: Likewise.
* tests/tail/inotify-dir-recreate.sh: Likewise.
* tests/tail/inotify-hash-abuse.sh: Likewise.
* tests/tail/inotify-hash-abuse2.sh: Likewise.
* tests/tail/inotify-parent-hash.sh: Likewise.
* tests/tail/inotify-rotate.sh: Likewise.
* tests/tail/pid.sh: Likewise.
* tests/tail/pipe-f2.sh: Likewise.
* tests/tail/retry.sh: Likewise.
* tests/tail/symlink.sh: Likewise.
* tests/tail/tail-n0f.sh: Likewise.
* tests/tail/truncate.sh: Likewise.
* tests/tail/wait.sh: Likewise.
* tests/tee/tee.sh: Likewise.
* tests/timeout/timeout-group.sh: Likewise.
* tests/rm/dangling-symlink.sh: Likewise.
Also avoid redundant cleanup_ calls.
* tests/tail/flush-initial.sh: Likewise.
* tests/tail/inotify-rotate-resources.sh: Likewise.
This commit is contained in:
Pádraig Brady committed 2026-10-25 13:11:49 +00:00
1 parent f3d8e1ce30
commit ff1141fcec
41 files changed
+41 -44

No files matched your search

+1 -1
View File
@@ -27,7 +27,7 @@ print_ver_ cat
mkfifo_or_skip_ fifo
# Terminate any background cp process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
echo 1 > exp
+1 -1
View File
@@ -40,7 +40,7 @@ chgrp $g2 fifo-copy &&
chmod g+r fifo-copy || framework-failure
# Terminate any background cp process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Copy a fifo's contents. That way, we can examine the
# destination permissions before they're finalized.
+1 -1
View File
@@ -26,7 +26,7 @@ umask 022
mkfifo_or_skip_ fifo
# Terminate any background cp process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Copy a fifo's contents. That way, we can examine the
# destination permissions before they're finalized.
+1 -1
View File
@@ -28,7 +28,7 @@ chmod g+s d 2>/dev/null # The cp test is valid either way.
# Terminate any background cp process.
pid=
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
for attr in mode ownership
do
+1 -1
View File
@@ -22,7 +22,7 @@ print_ver_ cp
require_sparse_support_
# Terminate any background cp process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
mkfifo_or_skip_ pipe
timeout 10 cat pipe > copy & pid=$!
+1 -1
View File
@@ -72,7 +72,7 @@ for i in $(seq 99); do
done
# Terminate any background cp process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Prohibit suspension, which could otherwise cause a timeout-induced FP failure.
trap '' TSTP
+1 -1
View File
@@ -20,7 +20,7 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
# Terminate any background processes
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
expected_failure_status_chroot=125
expected_failure_status_env=125
+1 -1
View File
@@ -51,7 +51,7 @@ returns_ 126 env . && { returns_ 126 stdbuf -o1 . || fail=1; } # invalid command
returns_ 127 stdbuf -o1 no_such || fail=1 # no such command
# Terminate any background processes
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Ensure line buffering stdout takes effect
stdbuf_linebuffer()
+1 -1
View File
@@ -40,7 +40,7 @@ test -r "$tty" 2>&1 \
|| skip_ '/dev/stdin is not readable'
# Terminate any background processes
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
mv f g < $tty > out 2>&1 & pid=$!
+1 -1
View File
@@ -56,7 +56,7 @@ trap_sigpipe_or_skip_
export MALLOC_PERTURB_=0
# Terminate any background process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
head -c 10 fifo > out & pid=$!
+1 -2
View File
@@ -26,7 +26,7 @@ ln -s no-file dangle
ln -s / symlink
# Terminate any background processes
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
rm ---presume-input-tty dangle symlink & pid=$!
# The buggy rm (fileutils-4.1.9) would hang here, waiting for input.
@@ -41,6 +41,5 @@ check_files_removed() {
}
retry_delay_ check_files_removed .1 6 || fail=1
cleanup_
Exit $fail
+1 -1
View File
@@ -26,7 +26,7 @@ ls /dev/stdin >/dev/null 2>&1 \
|| skip_ 'there is no /dev/stdin file'
# Terminate any background processes
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
touch f
chmod 0 f
+1 -1
View File
@@ -21,7 +21,7 @@ print_ver_ sort
expensive_
# Terminate any background processes
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
SORT_FAILURE=2
+1 -1
View File
@@ -30,7 +30,7 @@ grep '^#define HAVE_PTHREAD_T 1' "$CONFIG_HEADER" > /dev/null ||
skip_ 'requires pthreads'
# Terminate any background processes
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
seq 100000 > in || framework_failure_
mkfifo_or_skip_ fifo
+1 -1
View File
@@ -29,7 +29,7 @@ check_tail_output()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -29,7 +29,7 @@ check_tail_output()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -35,7 +35,7 @@ check_tail_output() {
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -22,7 +22,7 @@ print_ver_ tail
require_root_
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
chattr_a_works=1
touch f
+1 -1
View File
@@ -29,7 +29,7 @@ check_tail_output()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -34,7 +34,7 @@ check_tail_output()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -20,7 +20,7 @@
print_ver_ tail
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
cleanup_fail_ ()
{
+1 -1
View File
@@ -29,7 +29,7 @@ check_tail_output()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -2
View File
@@ -23,7 +23,7 @@ print_ver_ tail
fastpoll='-s.1 --max-unchanged-stats=1'
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
echo line > in || framework_failure_
# Output should be buffered since we're writing to file
@@ -39,6 +39,5 @@ tail_flush()
}
retry_delay_ tail_flush .1 5 || fail=1
cleanup_
Exit $fail
+1 -1
View File
@@ -32,7 +32,7 @@ compare exp err || fail=1
# Between coreutils 8.34 and 9.5 inclusive, with inotify, tail would
# have waited indefinitely when a file was moved to the same file system.
# Also without inotify tail would have exited with success.
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
fastpoll='-s.1 --max-unchanged-stats=1' # speedup non inotify systems
for inotify in '' '---disable-inotify'; do
touch file || framework_failure_
+1 -1
View File
@@ -30,7 +30,7 @@ check_tail_output()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -27,7 +27,7 @@ check_tail_output()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -23,7 +23,7 @@ print_ver_ tail
require_inotify_supported_
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
cleanup_fail_ ()
{
+1 -1
View File
@@ -31,7 +31,7 @@ check_tail_output()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -21,7 +21,7 @@
print_ver_ tail
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -28,7 +28,7 @@ check_tail_output()
{ sleep $delay; return 1; }
}
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
cleanup_fail()
{
+1 -2
View File
@@ -48,7 +48,7 @@ cleanup_fail()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill $pid 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
fastpoll='-s.1 --max-unchanged-stats=1'
@@ -99,6 +99,5 @@ for i in $(seq 2); do
>out && >strace.out || framework_failure_ 'failed to reset output files'
done
cleanup_
Exit $fail
+1 -1
View File
@@ -33,7 +33,7 @@ check_tail_output()
grep_timeout() { tail_re="$1" retry_delay_ check_tail_output .1 8; }
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
cleanup_fail()
{
+1 -1
View File
@@ -23,7 +23,7 @@ getlimits_
touch empty here || framework_failure_
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
for mode in '' '---disable-inotify'; do
# Use tail itself to create a background process to monitor,
+1 -1
View File
@@ -24,7 +24,7 @@ mkfifo_or_skip_ fifo
echo 1 > exp || framework_failure_
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -37,7 +37,7 @@ wait4lines_ ()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -37,7 +37,7 @@ wait4lines_ ()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# speedup non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -36,7 +36,7 @@ tail -c0 unreadable || fail=1
tail -n0 unreadable || fail=1
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
for mode in '' '---disable-inotify'; do
for file in empty nonempty; do
+1 -1
View File
@@ -27,7 +27,7 @@ check_tail_output()
}
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Speedup the non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -29,7 +29,7 @@ touch here || framework_failure_
{ touch unreadable && chmod a-r unreadable; } || framework_failure_
# Terminate any background tail process
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# speedup non inotify case
fastpoll='-s.1 --max-unchanged-stats=1'
+1 -1
View File
@@ -100,7 +100,7 @@ mkfifo_or_skip_ fifo
# Ensure tee handles nonblocking output correctly
# Terminate any background processes
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
read_fifo_delayed() {
{ sleep .1; timeout 10 dd of=/dev/null status=none; } <fifo
}
+1 -1
View File
@@ -84,7 +84,7 @@ check_timeout_cmd_exiting()
}
# Terminate any background processes
cleanup_() { kill $pid 2>/dev/null && wait $pid; }
cleanup_() { kill "$pid" 2>/dev/null; wait "$pid" 2>/dev/null; pid=; }
# Start above script in its own group.
# We could use timeout for this, but that assumes an implementation.