X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:to:subject:message-id:reply-to
	:references:mime-version:content-type:content-transfer-encoding
	:in-reply-to; q=dns; s=default; b=SM6MOTBVLnK1F2X56MiKwgDvJElB/N
	bQW1mNNW9/Nte+Z8uryMqM3G75HoXTtOQFvJKZYN342DmhzXhR5E6X9pGwIzOgm7
	1xylkcrjvdn8Bw6+zuW/2JDLctlPq5wdfIDaDr2cXKrZgpfZCSmKwa4wlpPt945g
	55rJ6fQFxPTwQ=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:date:from:to:subject:message-id:reply-to
	:references:mime-version:content-type:content-transfer-encoding
	:in-reply-to; s=default; bh=FKoDCX8kQK3zQl3zx3c2d+ngR4M=; b=c8kB
	D44tGYyp4ME7kLONklw7j+DMBVS0Y78WVm6tJrt8J5TN1tk6sF8dIqqzdARjrCvn
	syF+jEtcTeWuGYCjSd1uJdMWk1eXOg2aqBG+Dw6QrlNgyJcgSVdNs9TzixqaUA1b
	LcTlQamfa8VqtT37zOZGrHF6mAxiotY3VmS42rM=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL,BAYES_40,RDNS_NONE autolearn=no version=3.3.1
Date: Wed, 17 Jul 2013 15:45:32 +0200
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Issue with run.exe and PWD with spaces since last update (Cygwin 1.7.21)
Message-ID: <20130717134532.GC32258@calimero.vinschen.de>
Reply-To: cygwin@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
References: <295777180.20130716202913@mtu-net.ru> <20130717125916.GB21347@calimero.vinschen.de> <51E69DE2.10008@cwilson.fastmail.fm>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <51E69DE2.10008@cwilson.fastmail.fm>
User-Agent: Mutt/1.5.21 (2010-09-15)

On Jul 17 09:36, Charles Wilson wrote:
> On 7/17/2013 8:59 AM, Corinna Vinschen wrote:
> >This never works, even in any other directory.  It's the same problem
> >which disallows checkX to work, as reported in
> >http://cygwin.com/ml/cygwin/2013-07/msg00326.html
> >
> >The cause is an optimization when calling cygwin executables.  So far,
> >Cygwin executables got their arguments via mmeory copy as well as via
> >the single-line cmdline argument of CreateProcess.  We removed the
> >latter since it was never meant to work that way in the first place.
> >
> >Unfortunately it turns out that run/run2/checkX are Cygwin executables
> >which don't have a main routine, but rather a WinMain routine.  The
> >latter has a single cmdline argument, which is generated via
> >GetCommandLine().  But since Cygwin executables get no single-line
> >command line anymore, this stopped working.
> 
> This is a pretty unusual situation. I don't know of any other tool
> -- except perhaps the old frankenstein half-cygwin-half-win32
> tclsh.exe and wish.exe -- that does this, outside of run, run2, and
> checkX.  All of which are cygwin-specific (or, at least, cygwin +
> mingw specific).
> 
> Could we add a new cygwin_internal routine that triggers the
> allocation, creation and return of a suitable single-line command?
> Then run & friends could do (pseudo-code):
> 
> WinMain()
> {
>    LPCSTR s = GetCommandLine()
> #ifdef __CYGWIN__
>    if s empty
>       s = (LPCSTR) cygwin_internal(CW_WIN32_COMMAND_LINE)
> #endif

That should be unnecessary.  The culprit here is the default main
routine in cygwin's libcmain.c, which calls WinMain if the executable
doesn't provide its own main.

It doesn't construct the single-line commandline from argv, but rather
it calls GetCommandLinė.  This, obviously, creates an empty command line
for WinMain.

So, the actual fix is to change libcmain's main() routine to create
WinMain's cmdline arg from argc/argv.

However, either way, you will have to rebuild run/run2 for both
architectures since libcmain.c is linked statically to the executable.

So, if we do it this way, we should probably upload a new Cygwin DLL
with the patched libcmain ASAP, so you can rebuild against the new
libcmain.  Or, actually it would be better you would test this as soon
as we made the patch, *before* releasing a new Cygwin DLL.

Anyway, if we do it that way, let's hope no other tool is doing the
same...


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

