Mail Archives: cygwin/2004/09/10/09:56:46
On Fri, 10 Sep 2004, Christopher Faylor wrote:
> On Fri, Sep 10, 2004 at 12:38:31AM -0400, Igor Pechtchanski wrote:
> >Hi,
> >
> >I'm getting the following behavior consistently:
> >[snip]
> >In other words, invoking a Cygwin program sets argv[0] correctly, but
> >invoking a Windows program doesn't. Interestingly enough, using the MinGW
> >execv works properly:
>
> There is no such thing as "argv[0]" for a Windows program. Cygwin uses
> CreateProcess to create processes. CreateProcess does not have the concept
> of "argv[0]". 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[0] is
extracted from the command line one (well, unless the image name is NULL,
in which case the image name and argv[0] are the same). That's the value
of argv[0] that I meant.
Now, spawn_guts() *seems* to retain the original (correct) argv[0] when
constructing the command line string, but it apparently replaces it with
the prog_arg parameter somewhere for Windows programs...
Hmm, wait a minute, now that I phrased it this way, I think it enabled me
to find the culprit. Lines 513-515 of spawn.cc say:
/* Replace argv[0] with the full path to the script if this is the
first time through the loop. */
newargv.replace0_maybe (prog_arg);
Is there a particular reason why this is done for ".exe" files?
Thanks,
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT 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
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -