diff options
author | Spencer Janssen <spencerjanssen@gmail.com> | 2009-01-17 05:00:24 +0100 |
---|---|---|
committer | Spencer Janssen <spencerjanssen@gmail.com> | 2009-01-17 05:00:24 +0100 |
commit | 31642b5d699553452e7847579b83a388649885d5 (patch) | |
tree | 6d05206c870d3f3e22c3ef285f88f9f988957f83 | |
parent | 940965556c4c7ca0877f8c6bdef5c8dc2a9fca16 (diff) | |
download | metatile-31642b5d699553452e7847579b83a388649885d5.tar metatile-31642b5d699553452e7847579b83a388649885d5.zip |
Close stdin in spawned processes
Ignore-this: 2e372ed6215160adae8da1c44cdede3d
darcs-hash:20090117040024-25a6b-4083a1b37e7f5c55cb7ee03c5edf46350bacdbf0
-rw-r--r-- | XMonad/Core.hs | 11 |
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. |