diff options
author | Spencer Janssen <spencerjanssen@gmail.com> | 2009-01-16 22:03:15 +0100 |
---|---|---|
committer | Spencer Janssen <spencerjanssen@gmail.com> | 2009-01-16 22:03:15 +0100 |
commit | 7ddf106694c6174200d84e75055b4e13f5719e02 (patch) | |
tree | 0f2162e4636ed549b63c0766f6af2a93b28c9b02 /XMonad/Util/Run.hs | |
parent | dbe81eab127b22ba808ac630cd27f5eccdd1d557 (diff) | |
download | XMonadContrib-7ddf106694c6174200d84e75055b4e13f5719e02.tar.gz XMonadContrib-7ddf106694c6174200d84e75055b4e13f5719e02.tar.xz XMonadContrib-7ddf106694c6174200d84e75055b4e13f5719e02.zip |
Update all uses of doubleFork/waitForProcess
Ignore-this: 4e15b7f3fd6af3b7317449608f5246b0
darcs-hash:20090116210315-25a6b-53190793833624e0c5e36ce353333092e5243883.gz
Diffstat (limited to 'XMonad/Util/Run.hs')
-rw-r--r-- | XMonad/Util/Run.hs | 13 |
1 files changed, 7 insertions, 6 deletions
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 |