Support osx via `gtimeout`

pull/27/head
Phaninder Pasupula 8 years ago committed by GitHub
parent e1f115e4ca
commit a62579e32f

@ -5,6 +5,15 @@ cmdname=$(basename $0)
echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
timeout_cmd="timeout"
if [ $(uname -s) = "Darwin" ] && ! which $timeout_cmd 2>&1 >/dev/null; then
timeout_cmd="gtimeout"
if ! which $timeout_cmd 2>&1 >/dev/null; then
echo "Can't find the command 'gtimeout'. Run 'brew install coreutils' to install it."
exit 1
fi
fi
usage()
{
cat << USAGE >&2
@ -48,9 +57,9 @@ wait_for_wrapper()
{
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
if [[ $QUIET -eq 1 ]]; then
timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
$timeout_cmd $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
else
timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
$timeout_cmd $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
fi
PID=$!
trap "kill -INT -$PID" INT

Loading…
Cancel
Save