From 66e6f51b732d351577bc04b4d6e21c8c20807840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 6 Dec 2022 20:35:37 +0100 Subject: Kill process when it does not terminate within a second --- src/Process.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Process.hs b/src/Process.hs index 8548e73..a1a421f 100644 --- a/src/Process.hs +++ b/src/Process.hs @@ -9,6 +9,7 @@ module Process ( ) where import Control.Arrow +import Control.Concurrent import Control.Concurrent.STM import Control.Monad.Except @@ -89,6 +90,9 @@ closeProcess p = do Nothing -> return () Just pid -> signalProcess sig pid + liftIO $ void $ forkIO $ do + threadDelay 1000000 + terminateProcess $ procHandle p liftIO (waitForProcess (procHandle p)) >>= \case ExitSuccess -> return () ExitFailure code -> do -- cgit v1.2.3