diff options
author | Spencer Janssen <spencerjanssen@gmail.com> | 2009-12-23 07:16:23 +0100 |
---|---|---|
committer | Spencer Janssen <spencerjanssen@gmail.com> | 2009-12-23 07:16:23 +0100 |
commit | e3650fa208a29186feaaf9b70ea43786dadf872d (patch) | |
tree | 8c2ca2625e1ce799f54c76f13fd12eb78a673e5d | |
parent | afb6ed7f8c314302a271b47ee50c3f0358153985 (diff) | |
download | metatile-e3650fa208a29186feaaf9b70ea43786dadf872d.tar metatile-e3650fa208a29186feaaf9b70ea43786dadf872d.zip |
Add xfork: a forkProcess that works around process global state
Ignore-this: 3f968260d8c1b6710c82566520c47c43
darcs-hash:20091223061623-25a6b-3b3cc5f1a12543336e5b8581f9798989c4d848ac
-rw-r--r-- | XMonad/Core.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/XMonad/Core.hs b/XMonad/Core.hs index 0961235..b0713d7 100644 --- a/XMonad/Core.hs +++ b/XMonad/Core.hs @@ -27,7 +27,7 @@ module XMonad.Core ( StateExtension(..), ExtensionClass(..), runX, catchX, userCode, userCodeDef, io, catchIO, installSignalHandlers, uninstallSignalHandlers, withDisplay, withWindowSet, isRoot, runOnWorkspaces, - getAtom, spawn, spawnPID, getXMonadDir, recompile, trace, whenJust, whenX, + getAtom, spawn, spawnPID, xfork, getXMonadDir, recompile, trace, whenJust, whenX, atom_WM_STATE, atom_WM_PROTOCOLS, atom_WM_DELETE_WINDOW, ManageHook, Query(..), runQuery ) where @@ -395,10 +395,14 @@ spawn x = spawnPID x >> return () -- | Like 'spawn', but returns the 'ProcessID' of the launched application spawnPID :: MonadIO m => String -> m ProcessID -spawnPID x = io . forkProcess . finally nullStdin $ do +spawnPID x = xfork $ executeFile "/bin/sh" False ["-c", x] Nothing + +-- | A replacement for 'forkProcess' which resets default signal handlers. +xfork :: MonadIO m => IO () -> m ProcessID +xfork x = io . forkProcess . finally nullStdin $ do uninstallSignalHandlers createSession - executeFile "/bin/sh" False ["-c", x] Nothing + x where nullStdin = do fd <- openFd "/dev/null" ReadOnly Nothing defaultFileFlags |