[MLton] Re: [MLton-commit] r6699

Matthew Fluet fluet at tti-c.org
Wed Jun 17 19:34:20 PDT 2009


On Thu, 18 Jun 2009, Wesley W. Terpstra wrote:
> On Wed, Jun 17, 2009 at 9:47 PM, Matthew Fluet<fluet at tti-c.org> wrote:
>> Cygwin most definitely "lies" when providing the result for
>> Posix.ProcEnv.environ.  There seem to be a number of environment variables
>> that Cygwin translates between Windows paths and Cygwin paths:
>
> You make it sound like these cygwinify and uncygwinify functions are
> easy to use.

Aren't the cygwinify functions simply:
   cygwin_conv_to_full_posix_path
   cygwin_conv_to_posix_path
   cygwin_win32_to_posix_path_list
   cygwin_win32_to_posix_path_list_buf_size
and the uncygwinify functions simply:
   cygwin_conv_to_full_win32_path
   cygwin_conv_to_win32_path
   cygwin_posix_to_win32_path_list
   cygwin_posix_to_win32_path_list_buf_size
from http://cygwin.com/cygwin-api/cygwin-functions.html?

> Maybe we should consider uncygwinifying the name of the
> executable passed to CreateProcess? At the moment everything else in
> MLton (file/dir open, exec/spawn, ...) uses cygwin paths, but
> Process.create does not.

??Confused??  MLton.Process.create (on Cygwin) has used 
cygwin_conv_to_full_win32_path since your 20041202 patch 
(http://mlton.org/pipermail/mlton/2004-December/026368.html), slightly 
modified by Stephen (moving the cygwin_conv_to_full_win32_path call 
out of MLton_Process_create and performing the conversion on the SML 
side) when applied as r3662 
(http://mlton.org/cgi-bin/viewsvn.cgi?view=rev&rev=3662).

>> The Cygwin spawnv{,p}e functions only replicate the given environment
>> variables (but do uncygwinify the paths of select variables) and construct
>> an explicit environment for use as lpEnvironment for the underlying
>> CreateProcess call.
>>
>> Another option would be to mimic Cygwin's implementation of spawnv{,p} and
>> uncygwinify the paths of select variables from Posix.ProcEnv.eviron;
>
> This sounds like a good idea to me.
>
>> it's just not documented which variables.
>
> The cygwin installer can also grab source code for packages. Whichever
> package builds cygwin1.dll must mention these special paths.
> Alternatively, run 'strings' on cygwin1.dll and look for paths you
> know are translated and see which other strings are nearby?

It was fairly easy to find in the cygwin sources:
   http://cygwin.com/cgi-bin/cvsweb.cgi/~checkout~/src/winsup/cygwin/environ.cc?content-type=text/plain&cvsroot=src
Look for conv_envvars.

But, I'm not convinced that it is worth it.  Reading the archives from 
200411/200412, it is clear that Cygwin+CreateProcess has never really been 
tested.  Indeed, trying to redirect the child's stdout to the parent's 
stdout using Param.self doesn't work at the terminal (though it works when 
the parent's stdout is redirected to a file).


More information about the MLton mailing list