make safeCommand stop the process if the thread gets killed

And a comment on a todo item that this commit is perhaps the start of
solving.
This commit is contained in:
Joey Hess 2020-06-03 12:52:11 -04:00
parent 156e728b56
commit e1fc4f7594
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 36 additions and 3 deletions

View file

@ -81,9 +81,9 @@ safeSystem :: FilePath -> [CommandParam] -> IO ExitCode
safeSystem command params = safeSystem' command params id
safeSystem' :: FilePath -> [CommandParam] -> (CreateProcess -> CreateProcess) -> IO ExitCode
safeSystem' command params mkprocess = do
(_, _, _, pid) <- createProcess p
waitForProcess pid
safeSystem' command params mkprocess =
withCreateProcess p $ \_ _ _ pid ->
waitForProcess pid
where
p = mkprocess $ proc command (toCommand params)