This is the mail archive of the cygwin-developers mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: The GetCommandLine/WinMain "problem"


On Wed, Apr 05, 2006 at 02:04:34PM -0400, Pierre A. Humblet wrote:
>cgf wrote:
>>I meant GetEnvironmentVariable{W,A} and any other function which deals
>>with environment variables.
>>
>>I don't see how returning information from the cygwin environment would
>>affect you since any environment variables set in the windows
>>environment would also show up in cygwin's environment.  So, an emulated
>>GetEnvironmentVariable would return the proper thing no matter how the
>>process was started.
>>
>>If it does cause problems due to something like the initialization order
>>of the environment vs. when malloc_init is called, then that's something
>>that can be ironed out.  Just a simple check of whether or not environ
>>is initialized should be adequate to cause any environment manipulating
>>function to revert to using the windows environment.
>
>Yes, the basic problem is that Cygwin uses malloc (redirected to dmalloc)
>to build its environment, while dmalloc reads the environment when it's
>called for the first time (in malloc_init, well before the Cygwin 
>environment exists).

>Depending on whether it's called from Windows or Cygwin,
>one should then revert to using the Windows environment or
>reading envp on the cygheap.

I think we're going down a rat hole here.

The result of calling GetEnvironment* (and any related functions) should
be consistent whether the cygwin process is called from another cygwin
process or not.  If there is no cygwin environment (yet) then, of
course, we should fall back to the windows environment.

If we go down this path, that is how it will be implemented.

If this isn't what you want, then you can put -lkernel32 on your link
command line.

I'd like to move away from the minutia of perceived potential problems
with dmalloc and hear if there are any objections or observations with
what I was actually proposing.

cgf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]