POpen, opening lots of processes

Glynn Clements glynn.clements at virgin.net
Sat Jan 10 22:18:00 EST 2004

Mark Carroll wrote:

>    Your code looks great, but where do you find the library documentation,
> like what the arguments for executeFile are all about? (I'd guessed the
> Maybe thing was an environment, but what's the Bool?) I've been trying to
> do similar stuff, but have been stumbling in the dark rather.

Source code (hslibs/posix/PosixProcPrim.lhs):

	executeFile :: FilePath			    -- Command
	            -> Bool			    -- Search PATH?
	            -> [String]			    -- Arguments
	            -> Maybe [(String, String)]	    -- Environment
	            -> IO ()
	executeFile path search args Nothing = do
		if search 
		   then throwErrnoIfMinus1_ "executeFile" (c_execvp s arr)
		   else throwErrnoIfMinus1_ "executeFile" (c_execv s arr)

	executeFile path search args (Just env) = do
		if search 
		   then throwErrnoIfMinus1_ "executeFile" (c_execvpe s arg_arr env_arr)
		   else throwErrnoIfMinus1_ "executeFile" (c_execve s arg_arr env_arr)


	search	env		function

	False	Nothing		execv
	True	Nothing		execvp
	False	Just _		execve
	True	Just _		execvpe [*]

[*] execvpe() isn't a standard library function; it is implemented in
hslibs/posix/cbits/execvpe.c using execve().

Glynn Clements <glynn.clements at virgin.net>

More information about the Glasgow-haskell-users mailing list