From 246208e3cf75498790764b7e188e4c720b478c04 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Wed, 28 Dec 2022 20:11:20 -0500 Subject: [PATCH] REF clean up process --- lib/XMonad/Internal/Process.hs | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/lib/XMonad/Internal/Process.hs b/lib/XMonad/Internal/Process.hs index 79f3d21..c49235c 100644 --- a/lib/XMonad/Internal/Process.hs +++ b/lib/XMonad/Internal/Process.hs @@ -3,7 +3,7 @@ module XMonad.Internal.Process ( waitUntilExit - , killHandle + -- , killHandle -- , spawnPipe' -- , spawnPipe -- , spawnPipeArgs @@ -21,14 +21,14 @@ import Control.Exception import Control.Monad import Control.Monad.IO.Class -import Data.Maybe +-- import Data.Maybe import qualified RIO.Text as T import System.Directory import System.Exit import System.IO -import System.Posix.Signals +-- import System.Posix.Signals import System.Process import XMonad.Core hiding (spawn) @@ -42,17 +42,9 @@ import XMonad.Core hiding (spawn) waitUntilExit :: Show t => t -> IO () waitUntilExit pid = do res <- doesDirectoryExist $ "/proc/" ++ show pid - when res $ threadDelay 100000 >> waitUntilExit pid - -killHandle :: ProcessHandle -> IO () -killHandle ph = do - ec <- getProcessExitCode ph - unless (isJust ec) $ do - pid <- getPid ph - forM_ pid $ signalProcess sigTERM - -- this may fail if the process exits instantly and the handle - -- is destroyed by the time we get to this line (I think?) - void (try $ waitForProcess ph :: IO (Either IOException ExitCode)) + when res $ do + threadDelay 100000 + waitUntilExit pid withDefaultSignalHandlers :: IO a -> IO a withDefaultSignalHandlers = @@ -81,16 +73,3 @@ spawn = io . void . createProcess' . shell' spawnAt :: MonadIO m => FilePath -> String -> m () spawnAt fp cmd = io $ void $ createProcess' $ (shell' cmd) { cwd = Just fp } - --- spawnPipe' :: CreateProcess -> IO (Handle, ProcessHandle) --- spawnPipe' cp = do --- -- ASSUME creating a pipe will always succeed in making a Just Handle --- (Just h, _, _, p) <- createProcess' $ cp { std_in = CreatePipe } --- hSetBuffering h LineBuffering --- return (h, p) - --- spawnPipe :: String -> IO (Handle, ProcessHandle) --- spawnPipe = spawnPipe' . shell - --- spawnPipeArgs :: FilePath -> [String] -> IO (Handle, ProcessHandle) --- spawnPipeArgs cmd = spawnPipe' . proc cmd