summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSpencer Janssen <sjanssen@cse.unl.edu>2007-11-19 04:03:53 +0100
committerSpencer Janssen <sjanssen@cse.unl.edu>2007-11-19 04:03:53 +0100
commitd453a0add31502345c84d42defbc81d1f98c0e82 (patch)
tree1c12847a0f96b76a40494be10cf805675ed5d6e9
parent6a085c3da654d9f921af1799ad646112bc5b83cc (diff)
downloadmetatile-d453a0add31502345c84d42defbc81d1f98c0e82.tar
metatile-d453a0add31502345c84d42defbc81d1f98c0e82.zip
Factor out doubleFork logic
darcs-hash:20071119030353-a5988-935fc83135dc394c1e1a757f0232022b4de96f01
-rw-r--r--XMonad/Core.hs18
1 files changed, 8 insertions, 10 deletions
diff --git a/XMonad/Core.hs b/XMonad/Core.hs
index d533bf6..e873848 100644
--- a/XMonad/Core.hs
+++ b/XMonad/Core.hs
@@ -270,9 +270,14 @@ catchIO f = liftIO (f `catch` \e -> hPrint stderr e >> hFlush stderr)
-- | spawn. Launch an external application
spawn :: MonadIO m => String -> m ()
-spawn x = liftIO $ do
+spawn x = doubleFork $ executeFile "/bin/sh" False ["-c", x] Nothing
+
+-- | Double fork and execute an IO action (usually one of the exec family of
+-- functions)
+doubleFork :: MonadIO m => IO () -> m ()
+doubleFork m = liftIO $ do
pid <- forkProcess $ do
- forkProcess (createSession >> executeFile "/bin/sh" False ["-c", x] Nothing)
+ forkProcess (createSession >> m)
exitWith ExitSuccess
getProcessStatus True False pid
return ()
@@ -324,14 +329,7 @@ recompile = do
let msg = unlines $
["Error detected while loading xmonad configuration file: " ++ src]
++ lines ghcErr ++ ["","Please check the file for errors."]
- -- usual double fork for async processes, and no zombies.
- -- careful to use exec directly, avoiding shell
- -- interpreting chars in the command line args
- pid <- forkProcess $ do
- forkProcess $ createSession >> executeFile "xmessage" True [msg] Nothing
- exitWith ExitSuccess
- getProcessStatus True False pid
- return ()
+ doubleFork $ executeFile "xmessage" True [msg] Nothing
-- | Run a side effecting action with the current workspace. Like 'when' but
whenJust :: Monad m => Maybe a -> (a -> m ()) -> m ()