Files
swift-mirror/test/1_stdlib/timeout.sh
Jordan Rose e83c117c30 [test] Hack: run stdlib tests first to start long-running tests earlier.
This decreases total testing time by over a minute on my old Mac Pro.
It probably has much less effect on systems with fewer cores, but shouldn't
be any worse there.

Swift SVN r22745
2014-10-15 01:30:51 +00:00

22 lines
330 B
Bash
Executable File

#!/bin/bash
# timeout.sh <seconds> <command...>
# watchdog PID SECONDS
function watchdog() {
(( seconds = "$2" ))
while (( seconds > 0 ))
do
kill -0 $1 || exit
sleep 1
(( seconds -= 1 ))
done
echo "** timeout.sh: Timed out" 1>&2
kill -ALRM $1
}
watchdog $$ $1 &
shift
exec "$@"