summaryrefslogtreecommitdiff
path: root/tests/cp/parent-perm-race.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cp/parent-perm-race.sh')
-rwxr-xr-xtests/cp/parent-perm-race.sh9
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/cp/parent-perm-race.sh b/tests/cp/parent-perm-race.sh
index b7ea9143..c370f9e0 100755
--- a/tests/cp/parent-perm-race.sh
+++ b/tests/cp/parent-perm-race.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure cp -pR --parents isn't too generous with parent permissions.
-# Copyright (C) 2006-2014 Free Software Foundation, Inc.
+# Copyright (C) 2006-2015 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -26,6 +26,8 @@ umask 002
mkdir mode ownership d || framework_failure_
chmod g+s d 2>/dev/null # The cp test is valid either way.
+# Terminate any background cp process
+cleanup_() { kill $pid 2>/dev/null && wait $pid; }
for attr in mode ownership
do
@@ -33,8 +35,7 @@ do
# Copy a fifo's contents. That way, we can examine d/$attr's
# state while cp is running.
- cp --preserve=$attr -R --copy-contents --parents $attr d &
- cp_pid=$!
+ cp --preserve=$attr -R --copy-contents --parents $attr d & pid=$!
(
# Now 'cp' is reading the fifo.
@@ -58,7 +59,7 @@ do
fail=1;;
esac
- wait $cp_pid || fail=1
+ wait $pid || fail=1
done
Exit $fail