7.9. POpen
Prev | Chapter 7. The `posix` package: POSIX support | Next

## 7.9. POpen

POpen provides a convenient way of sending string input to a subprocess and reading output from it lazily.

    popen :: FilePath			-- Command
          -> [String]			-- Arguments
          -> Maybe String			-- Input
          -> IO (String, String, ProcessID)	-- (stdout, stderr, pid)

`popen cmd args inp` executes `cmd` with `args` in a forked process. If `inp` is `Just str` then str in sent in a pipe to the standard input of the process. The output and error streams from the process are returned, together with the process id.

    popenEnvDir :: FilePath				-- Command
    	    -> [String]				-- Arguments
    	    -> Maybe String			-- Input
    	    -> Maybe [(String, String)]		-- Environment
    	    -> Maybe FilePath 			-- Working directory
    	    -> IO (String, String, ProcessID)	-- (stdout, stderr, pid)

`popenEnvDir cmd args inp env dir` like `popen` executes `cmd` with `args` in a forked process. If `inp` is `Just str` then str in sent in a pipe to the standard input of the process. If `env` is `Just pairs`, the command in executed in the environment specified by `pairs`, instead of the current one. If `dir` is `Just d` the command is executed in directory `d` instead of the current directory. The output and error streams from the process are returned, together with the process id.

Prev | Up | Next
7.8. POSIX Errors | Home | Chapter 8. The `text` package: text manipulation