run..Process borrow handles and escape argumentes - missing function?

Marc Weber marco-oweber at gmx.de
Tue Apr 24 08:31:36 EDT 2007


> Perhaps you just want to pass Nothing for the "Maybe Handle" arguments to 
> runProcess, which means "inherit from the parent process"?

Hi Simon.

Once again you are right.

> which means "inherit from the parent process"?
This is not documented. I've missed it completely.
When reading "Handle to use for ..." I assume nothing is used in the
other case
When reading "different handle used for ..." I would see it quite
differently. But this seems to be my personal weakness.

When thinking about it again it doesn't make much sense to
have no handle.
The process is executed asynchronously.
So when writing to stdout (either your application or the launched one)
it might make sense to let both write to the same handle.
But what happens if both want to read from stdin?
The one who asks wether there is some input first will retrieve it?

The extract from ghc-6.6-libraries/base/System/Process.hs:
-- ----------------------------------------------------------------------------
-- runProcess

{- | Runs a raw command, optionally specifying 'Handle's from which to
     take the @stdin@, @stdout@ and @stderr@ channels for the new
     process.  

     Any 'Handle's passed to 'runProcess' are placed immediately in the 
     closed state.
-}
runProcess
  :: FilePath			-- ^ Filename of the executable
  -> [String]			-- ^ Arguments to pass to the executable
  -> Maybe FilePath		-- ^ Optional path to the working directory
  -> Maybe [(String,String)]	-- ^ Optional environment (otherwise inherit)
  -> Maybe Handle		-- ^ Handle to use for @stdin@
  -> Maybe Handle		-- ^ Handle to use for @stdout@
  -> Maybe Handle		-- ^ Handle to use for @stderr@
  -> IO ProcessHandle

-- ----------------------------------------------------------------------------

Proposal:
     "take the @stdin@, @stdout@ and @stderr@ channels for the new
     process. [ add: Otherwise inherit from parent process]"

If this is changed it should be also changed in the runProcessPosix /
runProcessWin32 comments..

Marc


More information about the Libraries mailing list