[GHC] #7654: Cannot specify argv[0] with createProcess
GHC
cvs-ghc at haskell.org
Sat Feb 2 20:18:21 CET 2013
#7654: Cannot specify argv[0] with createProcess
-----------------------------+----------------------------------------------
Reporter: MtnViewMark | Owner:
Type: feature request | Status: new
Priority: normal | Component: libraries/process
Version: 7.6.2 | Keywords: process
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: None/Unknown | Blockedby:
Blocking: | Related:
-----------------------------+----------------------------------------------
There are conditions where it is important to specify the value of argv[0]
as distinct from the FilePath of the file to execute.
When createProcess is called with CmdSpec (inside the CreateProcess
argument) of RawCommand, the code in
System.Process.Internals.runGenProcess_ builds the argv list by
concatenating the FilePath of the command to run on to the supplied args,
then passing that array to the c code runInteractiveProcess.
runInteractiveProcess in turn uses argv[0] as the initial argument to
either execvp() or execvpe(). Thus, argv[0], and the command to execute
must be the same.
The fix is simple, but long.... runInteractiveProcess should take an
adiditional parameter that is the command to exec, distinct from the args
array (which continues to hold the now distinct argv[0]). runGenProcess_
should keep cmd and args distinct, and build cstrs from args, not
cmd:args. commandToProcess needs to then take on the work of prepending
the cmd to the args array, in the case of RawCommand or ShellCommand. NOW,
we can introduce a new constructore RawCommandWithArg0 FilePath String
[String] where argv[0] is specified, and commandToProcess for that can
easily build the args from that parameter.
I should probably prepare a patch for this.... But I wanted to get the
ticket in as the issue was fresh in my mind.
This is a feature request, but realize that without a change, an important
part of POSIX support is missing.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7654>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list