Skip to content
Snippets Groups Projects
Commit 2a7266f1 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

Kill child process instead of sending SIGTERM

If the child is currently between DisableInterrupts and
EnableInterrupts and we decide to terminate it, it will not respond to
sigterm.
parent c077adf5
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,7 @@ library
, microlens-th >= 0.4 && < 0.5
, unordered-containers >= 0.2 && <0.3
, hashable >= 1.2 && < 1.3
, unix >= 2.7 && <2.8
default-language: Haskell2010
ghc-options: -Wall -fno-warn-name-shadowing
......
......@@ -18,6 +18,8 @@ import qualified Data.Text.IO as T
import System.Exit
import System.IO
import System.Process
import System.Process.Internals (withProcessHandle, ProcessHandle__(..))
import System.Posix.Signals (signalProcess, sigKILL)
import Data.Aeson
import qualified Data.Graph.Inductive as G
......@@ -130,6 +132,12 @@ driver' elimEpsis dumpJSON debug prog startVertex = do
loop
killProcess :: ProcessHandle -> IO ()
killProcess handle = withProcessHandle handle $ \ph ->
case ph of
OpenHandle pid -> signalProcess sigKILL pid
_ -> return ()
oneProgRun :: FilePath -> DebugOutput -> IORef State -> Maybe [Bool] -> IO ()
oneProgRun prog debug state trace = do
(Just pstdin, Just pstdout, _, handle) <- createProcess (proc prog []) { std_in = CreatePipe, std_out = CreatePipe }
......@@ -144,7 +152,7 @@ oneProgRun prog debug state trace = do
let (next, s') = handleDecision x (s^.curTrace) s
writeIORef state s'
case next of
Restart -> terminateProcess handle >> mapM_ hClose [pstdin, pstdout]
Restart -> killProcess handle >> mapM_ hClose [pstdin, pstdout]
Continue x' -> do
makeDecision pstdin state x'
loop
......@@ -152,7 +160,7 @@ oneProgRun prog debug state trace = do
EOF -> do
getProcessExitCode handle >>= \case
Nothing -> -- process still running, send SIGTERM
terminateProcess handle
killProcess handle
Just ExitSuccess ->
return () -- do nothing
Just (ExitFailure code) -> do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment