summaryrefslogtreecommitdiff
path: root/tests/cp/sparse-to-pipe.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cp/sparse-to-pipe.sh')
-rwxr-xr-xtests/cp/sparse-to-pipe.sh7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/cp/sparse-to-pipe.sh b/tests/cp/sparse-to-pipe.sh
index 8fc9e09d6..2c3dcefba 100755
--- a/tests/cp/sparse-to-pipe.sh
+++ b/tests/cp/sparse-to-pipe.sh
@@ -21,14 +21,17 @@ print_ver_ cp
require_sparse_support_
+# Terminate any background cp process
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
+
mkfifo_or_skip_ pipe
-timeout 10 cat pipe > copy &
+timeout 10 cat pipe > copy & pid=$!
truncate -s1M sparse || framework_failure_
cp sparse pipe || fail=1
# Ensure that the cat has completed before comparing.
-wait
+wait $pid
cmp sparse copy || fail=1