2 % (c) The GRASP/AQUA Project, Glasgow University, 1995-1996
4 \section[Posix]{Haskell 1.3 POSIX bindings}
49 -- runProcess is our candidate for the high-level OS-independent primitive
50 -- If accepted, it will be moved out of Posix into LibSystem.
52 import Directory ( setCurrentDirectory )
55 runProcess :: FilePath -- Command
56 -> [String] -- Arguments
57 -> Maybe [(String, String)] -- Environment
58 -> Maybe FilePath -- Working directory
59 -> Maybe Handle -- stdin
60 -> Maybe Handle -- stdout
61 -> Maybe Handle -- stderr
63 runProcess path args env dir stdin stdout stderr =
64 forkProcess >>= \ pid ->
66 Nothing -> doTheBusiness
69 doTheBusiness :: IO ()
71 maybeChangeWorkingDirectory >>
75 executeFile path True args env >>
78 maybeChangeWorkingDirectory :: IO ()
79 maybeChangeWorkingDirectory =
82 Just x -> setCurrentDirectory x
84 maybeDup2 :: Int -> Maybe Handle -> IO ()
86 case h of Nothing -> return ()
87 Just x -> handleToFd x >>= \ src ->
88 dupTo src (intToFd dest) >>