summaryrefslogtreecommitdiff
path: root/tests/misc/sort-spinlock-abuse.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/misc/sort-spinlock-abuse.sh
parentc18578632fd3c9e513e613a86ba2b7c4ebee6c45 (diff)
downloadcoreutils-upstream.tar.gz
Imported Upstream version 8.24upstream/8.24upstream
Diffstat (limited to 'tests/misc/sort-spinlock-abuse.sh')
-rwxr-xr-xtests/misc/sort-spinlock-abuse.sh7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/misc/sort-spinlock-abuse.sh b/tests/misc/sort-spinlock-abuse.sh
index 49ed920f..e81abf80 100755
--- a/tests/misc/sort-spinlock-abuse.sh
+++ b/tests/misc/sort-spinlock-abuse.sh
@@ -2,7 +2,7 @@
# trigger a bug that would make parallel sort use 100% of one or more
# CPU while blocked on output.
-# Copyright (C) 2010-2014 Free Software Foundation, Inc.
+# Copyright (C) 2010-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
@@ -29,13 +29,16 @@ very_expensive_
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; }
+
seq 100000 > in || framework_failure_
mkfifo_or_skip_ fifo
# Arrange for sort to require 8.0+ seconds of wall-clock time,
# while actually using far less than 1 second of CPU time.
(for i in $(seq 80); do read line; echo $i; sleep .1; done
- cat > /dev/null) < fifo &
+ cat > /dev/null) < fifo & pid=$!
# However, under heavy load, it can easily take more than
# one second of CPU time, so set a permissive limit: