summaryrefslogtreecommitdiff
path: root/testsuite/timeout
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/timeout')
-rw-r--r--testsuite/timeout/timeout.hs12
1 files changed, 9 insertions, 3 deletions
diff --git a/testsuite/timeout/timeout.hs b/testsuite/timeout/timeout.hs
index b1a0192f3a..ca2eaf7a41 100644
--- a/testsuite/timeout/timeout.hs
+++ b/testsuite/timeout/timeout.hs
@@ -28,9 +28,15 @@ main :: IO ()
main = do
args <- getArgs
case args of
- [secs,cmd] -> run (read secs) cmd
- _ -> do hPutStrLn stderr $ "timeout: bad arguments " ++ show args
- exitWith (ExitFailure 1)
+ [secs,cmd] ->
+ case reads secs of
+ [(secs', "")] -> run secs' cmd
+ _ -> die ("Can't parse " ++ show secs ++ " as a number of seconds")
+ _ -> die ("Bad arguments " ++ show args)
+
+die :: String -> IO ()
+die msg = do hPutStrLn stderr ("timeout: " ++ msg)
+ exitWith (ExitFailure 1)
timeoutMsg :: String
timeoutMsg = "Timeout happened...killing process..."