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 | 1ce181eccefc47f35ef926f5d010d2c8ac678eaa (patch) | |
tree | 8c2ca2625e1ce799f54c76f13fd12eb78a673e5d /XMonad | |
parent | 6fe09d0ffd94781786c94fdd1adf3d100f9a23bd (diff) | |
download | xmonad-1ce181eccefc47f35ef926f5d010d2c8ac678eaa.tar.gz xmonad-1ce181eccefc47f35ef926f5d010d2c8ac678eaa.tar.xz xmonad-1ce181eccefc47f35ef926f5d010d2c8ac678eaa.zip |
Add xfork: a forkProcess that works around process global state
Ignore-this: 3f968260d8c1b6710c82566520c47c43
darcs-hash:20091223061623-25a6b-3b3cc5f1a12543336e5b8581f9798989c4d848ac.gz
Diffstat (limited to 'XMonad')
-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 |