Win32 process spawning, POpen and Hugs, revisited

Simon Marlow simonmar at microsoft.com
Thu Mar 18 10:20:20 EST 2004


My apologies to those who couldn't read the attachment.  I've put it
here;
  
  http://www.haskell.org/~simonmar/process/Process.hs

Haddock docs here:

  http://www.haskell.org/~simonmar/process/System.Process.html

> The abstraction could use an option to control whether 
> exiting or killing the parent process also terminates the child.

Good point.

> I'm not sure on what Windows foundation you are thinking of 
> implementing this, 
> but it's not easy to handle the command and arguments on the 
> Win32 API.  The 
> arguments are handled by the API as a raw string, so the 
> caller must quote 
> the arguments according to awkard (possibly undocumented) 
> rules.  I've worked 
> with this both in the Win32 API and using Perl. Perl didn't 
> have it right, so 
> in one case I was unable to invoke a certain command using 
> the full pathname, 
> because it contained spaces.

We've already solved this problem: see System.Cmd.rawSystem in GHC 6.2.
On Windows this translates the command line in such a way that the
program will see exactly the arguments that you pass to rawSystem.
Well, there's a small caveat: the target program has to be using
Microsoft's standard C runtime semantics for parsing the command line
(which pretty much everything does, I believe).

Cheers,
	Simon


More information about the Libraries mailing list