aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad
diff options
context:
space:
mode:
authorSpencer Janssen <spencerjanssen@gmail.com>2009-01-17 05:00:24 +0100
committerSpencer Janssen <spencerjanssen@gmail.com>2009-01-17 05:00:24 +0100
commite1def34de85c82441bee4b93a30cfee53daea0bc (patch)
tree6d05206c870d3f3e22c3ef285f88f9f988957f83 /XMonad
parent3b7f2e6cde48fa3c188d8d819373049b583219eb (diff)
downloadxmonad-e1def34de85c82441bee4b93a30cfee53daea0bc.tar.gz
xmonad-e1def34de85c82441bee4b93a30cfee53daea0bc.tar.xz
xmonad-e1def34de85c82441bee4b93a30cfee53daea0bc.zip
Close stdin in spawned processes
Ignore-this: 2e372ed6215160adae8da1c44cdede3d darcs-hash:20090117040024-25a6b-4083a1b37e7f5c55cb7ee03c5edf46350bacdbf0.gz
Diffstat (limited to 'XMonad')
-rw-r--r--XMonad/Core.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/XMonad/Core.hs b/XMonad/Core.hs
index 950a936..543d859 100644
--- a/XMonad/Core.hs
+++ b/XMonad/Core.hs
@@ -33,7 +33,7 @@ module XMonad.Core (
import XMonad.StackSet hiding (modify)
import Prelude hiding ( catch )
-import Control.Exception (catch, try, bracket, throw, Exception(ExitException))
+import Control.Exception (catch, try, bracket, throw, finally, Exception(ExitException))
import Control.Applicative
import Control.Monad.State
import Control.Monad.Reader
@@ -41,6 +41,7 @@ import System.IO
import System.Info
import System.Posix.Process (executeFile, forkProcess, getAnyProcessStatus)
import System.Posix.Signals
+import System.Posix.IO
import System.Posix.Types (ProcessID)
import System.Process
import System.Directory
@@ -356,7 +357,13 @@ 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 $ executeFile "/bin/sh" False ["-c", x] Nothing
+spawnPID x = io . forkProcess . finally nullStdin $
+ executeFile "/bin/sh" False ["-c", x] Nothing
+ where
+ nullStdin = do
+ fd <- openFd "/dev/null" ReadOnly Nothing defaultFileFlags
+ dupTo fd stdInput
+ closeFd fd
-- | This is basically a map function, running a function in the 'X' monad on
-- each workspace with the output of that function being the modified workspace.