-
Notifications
You must be signed in to change notification settings - Fork 16
Running commands with a timeout
Coreutils timeout command
During a reduction it can happen that a variant is produced that never finishes. Unless you are actively reducing for this condition, you'll probably want DustMite to ignore this variant, which is why the -s 0
option is used to change the default error code from 124
to 0
. If the process is seriously locked up it won't likely react to the default EXIT
signal, and require a KILL
signal as well. Options -k 5s 30s
will send the process the EXIT
signal after 30 seconds and the KILL
signal after an additional 5 seconds.
Replace testdir
with your test directory and sleep 60
with your test command:
dustmite testdir "timeout -s 0 -k 5s 30s sleep 60"
You can also use a script as the test command:
dustmite testdir "timeout -s 0 -k 5s 30s ../testscript.sh"
With Homebrew:
brew install coreutils
dustmite testdir "gtimeout -s 0 -k 5s 30s ../testscript.sh"
or with Macports:
port install timeout
dustmite testdir "timeout -s 0 -k 5s 30s ../testscript.sh"
If you have installed Git, the timeout
command is likely available as c:\Program Files\Git\usr\bin\timeout.exe
. However, if you are using a batch file to run the compiler and use timeout
on the batch file, then timeout
will kill the script when the compiler times out, but the compiler will keep on running nonetheless. So in order to kill the compiler, timeout
should be part of the script as follows. If you invoke DustMite as
dustmite testdir ..\testscript.bat
and testscript.bat
looked like
dmd main.d 2>&1 | "c:\Program Files\Git\usr\bin\grep.exe" -F -e "Error: out of memory" -e "Memory allocation failed"
then the script should become
"c:\Program Files\Git\usr\bin\timeout.exe" -s 0 -k 5s 30s dmd main.d 2>&1 | "c:\Program Files\Git\usr\bin\grep.exe" -F -e "Error: out of memory" -e "Memory allocation failed"