summaryrefslogtreecommitdiff
path: root/tests/cp/existing-perm-race.sh
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
commit71cd8e3a743046573744123777061b64881bf372 (patch)
tree82522befe647f4fff186a5630cad0cad33f8ef53 /tests/cp/existing-perm-race.sh
parentc18578632fd3c9e513e613a86ba2b7c4ebee6c45 (diff)
downloadcoreutils-upstream.tar.gz
Imported Upstream version 8.24upstream/8.24upstream
Diffstat (limited to 'tests/cp/existing-perm-race.sh')
-rwxr-xr-xtests/cp/existing-perm-race.sh10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/cp/existing-perm-race.sh b/tests/cp/existing-perm-race.sh
index c12cbb85..f48369cd 100755
--- a/tests/cp/existing-perm-race.sh
+++ b/tests/cp/existing-perm-race.sh
@@ -1,7 +1,7 @@
#!/bin/sh
# Make sure cp -p isn't too generous with existing file 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
@@ -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 &&