From 7ddf106694c6174200d84e75055b4e13f5719e02 Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Fri, 16 Jan 2009 22:03:15 +0100 Subject: Update all uses of doubleFork/waitForProcess Ignore-this: 4e15b7f3fd6af3b7317449608f5246b0 darcs-hash:20090116210315-25a6b-53190793833624e0c5e36ce353333092e5243883.gz --- XMonad/Util/Run.hs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'XMonad/Util/Run.hs') diff --git a/XMonad/Util/Run.hs b/XMonad/Util/Run.hs index 8e92ff4..dfc90b9 100644 --- a/XMonad/Util/Run.hs +++ b/XMonad/Util/Run.hs @@ -31,7 +31,7 @@ module XMonad.Util.Run ( ) where import System.Posix.IO -import System.Posix.Process (executeFile) +import System.Posix.Process (executeFile, forkProcess) import Control.Concurrent (threadDelay) import Control.Exception (try) import System.IO @@ -54,20 +54,20 @@ import Control.Monad -- This corresponds to dmenu's notion of exit code 1 for a cancelled invocation. runProcessWithInput :: FilePath -> [String] -> String -> IO String runProcessWithInput cmd args input = do - (pin, pout, perr, ph) <- runInteractiveProcess cmd args Nothing Nothing + (pin, pout, perr, _) <- runInteractiveProcess cmd args Nothing Nothing hPutStr pin input hClose pin output <- hGetContents pout when (output == output) $ return () hClose pout hClose perr - waitForProcess ph + -- no need to waitForProcess, we ignore SIGCHLD return output -- | Wait is in µs (microseconds) runProcessWithInputAndWait :: FilePath -> [String] -> String -> Int -> IO () runProcessWithInputAndWait cmd args input timeout = do - doubleFork $ do + forkProcess $ do (pin, pout, perr, ph) <- runInteractiveProcess cmd args Nothing Nothing hPutStr pin input hFlush pin @@ -77,6 +77,7 @@ runProcessWithInputAndWait cmd args input timeout = do hClose perr waitForProcess ph return () + return () -- | Multiplies by ONE MILLION, for functions that take microseconds. -- @@ -106,7 +107,7 @@ it makes use of shell interpretation by relying on @$HOME@ and interpolation, whereas the safeSpawn example can be safe because Firefox doesn't need any arguments if it is just being started. -} safeSpawn :: MonadIO m => FilePath -> String -> m () -safeSpawn prog arg = liftIO (try (doubleFork $ executeFile prog True [arg] Nothing) >> return ()) +safeSpawn prog arg = liftIO (try (forkProcess $ executeFile prog True [arg] Nothing) >> return ()) unsafeSpawn :: MonadIO m => String -> m () unsafeSpawn = spawn @@ -128,7 +129,7 @@ spawnPipe x = do setFdOption wr CloseOnExec True h <- fdToHandle wr hSetBuffering h LineBuffering - doubleFork $ do + forkProcess $ do dupTo rd stdInput executeFile "/bin/sh" False ["-c", x] Nothing return h -- cgit v1.2.3