From e1def34de85c82441bee4b93a30cfee53daea0bc Mon Sep 17 00:00:00 2001 From: Spencer Janssen Date: Sat, 17 Jan 2009 05:00:24 +0100 Subject: Close stdin in spawned processes Ignore-this: 2e372ed6215160adae8da1c44cdede3d darcs-hash:20090117040024-25a6b-4083a1b37e7f5c55cb7ee03c5edf46350bacdbf0.gz --- XMonad/Core.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'XMonad') 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. -- cgit v1.2.3