#7654 closed feature request (wontfix)

Cannot specify argv[0] with createProcess

Reported by: MtnViewMark Owned by: MtnViewMark
Priority: normal Milestone:
Component: libraries/process Version: 7.6.2
Keywords: process Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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.

Change History (4)

comment:1 Changed 15 months ago by igloo

  • Difficulty set to Unknown
  • Owner set to MtnViewMark

A patch would be great; please see http://www.haskell.org/haskellwiki/Library_submissions for details.

comment:2 Changed 15 months ago by igloo

  • Status changed from new to infoneeded

comment:3 Changed 15 months ago by simonmar

Is it possible to do this without breaking the API too much? I have in mind adding a new field to CreateProcess:

data CreateProcess = CreateProcess {
  ...
  argv0  :: Maybe String
  }

and leave the rest of the public API as it is.

comment:4 Changed 13 months ago by igloo

  • Resolution set to wontfix
  • Status changed from infoneeded to closed

I'm going to close this ticket until we've reached consensus on the libraries list, as per the library submissions policy.

Note: See TracTickets for help on using tickets.