summaryrefslogtreecommitdiff
path: root/tests/cp/existing-perm-race.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cp/existing-perm-race.sh')
-rwxr-xr-xtests/cp/existing-perm-race.sh8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/cp/existing-perm-race.sh b/tests/cp/existing-perm-race.sh
index 30cbc6ab6..f48369cd5 100755
--- a/tests/cp/existing-perm-race.sh
+++ b/tests/cp/existing-perm-race.sh
@@ -37,10 +37,12 @@ chgrp $g1 fifo &&
chgrp $g2 fifo-copy &&
chmod g+r fifo-copy || framework-failure
+# Terminate any background cp process
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+
# Copy a fifo's contents. That way, we can examine the
# destination permissions before they're finalized.
-cp -p --copy-contents fifo fifo-copy &
-cp_pid=$!
+cp -p --copy-contents fifo fifo-copy & pid=$!
(
# Now 'cp' is reading the fifo. Wait for the destination file to
@@ -77,7 +79,7 @@ case $mode in
*) fail=1;;
esac
-wait $cp_pid || fail=1
+wait $pid || fail=1
# Check that the final mode and group are right.
ls -l -n fifo-copy >ls.out &&