The GetCommandLine/WinMain "problem"
Pierre A. Humblet
Pierre.Humblet@ieee.org
Wed Apr 5 16:19:00 GMT 2006
I have no problem with the GetCommandLine issue, but
I am alarmed that you would touch GetEnvironmentVariable.
The reason is that I am fixing dmalloc to work on the current Cygwin.
It needs to read an environment variable when starting up (called
early, from malloc_init). If it's starting from Windows, it needs to use
GetEnvironmentVariable, or at least GetEnvironmentVariableA.
By the way, to make dmalloc work I need to
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dcrt0.cc,v
retrieving revision 1.303
diff -u -p -r1.303 dcrt0.cc
--- dcrt0.cc 3 Apr 2006 17:33:07 -0000 1.303
+++ dcrt0.cc 5 Apr 2006 16:07:53 -0000
@@ -784,7 +784,6 @@ static void
dll_crt0_1 (char *)
{
check_sanity_and_sync (user_data);
- malloc_init ();
#ifdef CGF
int i = 0;
const int n = 2 * 1024 * 1024;
@@ -794,6 +793,7 @@ dll_crt0_1 (char *)
user_data->resourcelocks->Init ();
user_data->threadinterface->Init ();
+ malloc_init ();
ProtectHandle (hMainProc);
ProtectHandle (hMainThread);
because dmalloc uses mmap which needs user_data->resourcelocks
Do you see any problem with that?
Pierre
----- Original Message -----
From: "Christopher Faylor" <me@cgf.cx>
To: <cygwin-developers@cygwin.com>
Sent: Wednesday, April 05, 2006 11:35 AM
Subject: The GetCommandLine/WinMain "problem"
> The problem which was recently reported in the cygwin list where
> good-old "GetCommandLine" no longer works (as invoked prior to calling
> WinMain) is due to changes that Corinna made to spawn_guts. She made it
> so that if cygwin detects that a to-be-execed process is a cygwin
> process it does not fill out the windows command line.
>
> I had resisted making this optimization, probably for exactly the case
> of GetCommandLine, but, now that it's there, I am loath to change it. I
> like the idea of spawn_guts not going to the effort of creating a
> windows command line when it knows it shouldn't have to.
>
> I don't know why the original creators of Cygwin decided that they had
> to implement WinMain handling when they were trying to create a system
> that built GNU tools that didn't use WinMain, but, regardless, I am
> thinking that maybe we should deprecate WinMain, GetCommandLine, and
> GetEnvironmentVariable and friends. I think that there probably aren't
> very many programs out there which use these.
>
> What we could do is export versions of these in libcygwin.a (not
> necessarily in cygwin1.dll). A Cygwin version of GetCommandLine[AW]
> would concatenate the contents of __argv and return a string.
> GetEnvironentVariable could do the same thing.
>
> This is a radical departure from our previously stated goal of "newer
> cygwin's always work" but, frankly, I'm getting very tired of hearing
> how slow cygwin is (read the git mailing list sometime) and I am even
> more tired of making accommodations which slow things down for people
> who are using Cygwin in ways that aren't in line with it's stated goals.
>
> Does anyone think that requiring people to relink their apps if they
> want to use these Windows-isms is a very bad idea? FWIW, I discovered a
> way around the problem that Corinna was fixing with her spawn_guts
> changes and Corinna has a patch waiting in the wings to implement it
> but... I'd rather not go with the patch. I'd like cygwin programs to
> just not worry about the windows command line (or windows environment
> variables) at all.
>
> cgf
More information about the Cygwin-developers
mailing list