This is the mail archive of the
mailing list for the Cygwin project.
RE: cygwin 1.5.11: execv doesn't set argv on Windows programs
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: Dave Korn <dk at artimi dot com>
- Cc: cygwin at cygwin dot com
- Date: Fri, 10 Sep 2004 13:00:04 -0400 (EDT)
- Subject: RE: cygwin 1.5.11: execv doesn't set argv on Windows programs
- References: <NUTMEGspH2q6DqaJY4k000012dd@NUTMEG.CAM.ARTIMI.COM>
- Reply-to: cygwin at cygwin dot com
On Fri, 10 Sep 2004, Dave Korn wrote:
> > -----Original Message-----
> > From: cygwin-owner On Behalf Of Igor Pechtchanski
> > Sent: 10 September 2004 14:57
> > On Fri, 10 Sep 2004, Christopher Faylor wrote:
> > > There is no such thing as "argv" for a Windows program. Cygwin
> > > uses CreateProcess to create processes. CreateProcess does not have
> > > the concept of "argv". Perhaps Microsoft's exec functions do
> > > something funky that is understood by other msvcrt programs.
> > > Cygwin doesn't do that.
> > Allow me to disagree. CreateProcess takes two separate arguments: the
> > image to run, and the command line (yes, as one long line). The
> > actual executable being run is the image parameter, but the value of
> > argv is extracted from the command line one (well, unless the image
> > name is NULL, in which case the image name and argv are the same).
> > That's the value of argv that I meant.
> Allow me to disagree! The Win32 API specifies precisely the form that
> the entry function of a win32 application must conform to:
> int WINAPI WinMain(
> HINSTANCE hInstance, // handle to current instance
> HINSTANCE hPrevInstance, // handle to previous instance
> LPSTR lpCmdLine, // command line
> int nCmdShow // show state
> There is no concept of argv in the windows OS itself. The application
> gets the entire commmand line as one unparsed string.
Fair enough. Thanks for the clarification.
What I meant was that the first token of the command line was set to the
image name when invoking Windows applications from Cygwin. So, even if a
Cygwin app sets argv explicitly (which should be incorporated into the
lpCmdLine), that first token would be the same as the image name, and not
what was specified.
> Now, it may well be the case that most applications link against the
> msvcrt library, which contains an implementation of WinMain that parses
> lpCmdLine into separate tokens, puts them into an array, and then calls
> out to a function named 'main' in the user's app that is linked with the
> library, passing it argc and argv parameters. But it's fair to point
> out that the argv concept is not part of the OS, it's part of a compiler
> support library; it's not handled by the OS, it's not passed to
> applications, it's not defined in the API, and there are plenty of
> applications that implement their own (or a predefined) WinMain in a
> different fashion and do _not_ tokenize and parse the command line; 99%
> of all MFC apps, for instance.
True, but irrelevant. My complaint was that the first token of the
command line, as specified by Cygwin's execv(), was ignored in favor of
the image name.
Hope this clarifies things,
|\ _,,,---,,_ firstname.lastname@example.org
ZZZzz /,`.-'`' -. ;-;;,_ email@example.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing." -- Dr. Jubal Harshaw
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html