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:from:to:references:in-reply-to:subject:date
	:message-id:mime-version:content-type:content-transfer-encoding;
	 q=dns; s=default; b=uIrWHJUS2p4Lg4/KVa+EuDHz3Yfd6+UEeuLEpXpJLdO
	CjX6GJ9xPt6UCy5z9i6xFNTkvmtJ6NGVdyHd+nzy4d4zIY44Y3Gv99hz45N7Pwdm
	vtaRQ5FqHIXn+Ie/xW+8ALnoO+ccuiBBBqqIbsmnJMj0seitPt4wro5JfxQNv1H8
	=
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:from:to:references:in-reply-to:subject:date
	:message-id:mime-version:content-type:content-transfer-encoding;
	 s=default; bh=zwd8lcqVfJrjQKJA8et5nicTyyM=; b=dPbDly8wTAWvtKoV/
	DN6PQqQAfLWm0zKkjqxxdgARbUxGdg1wLegUULUhmUO2PM/RJGGGY6kb4H2BpnNb
	cO4IsZ1nd9MIH+ew/H1K819UyU1nJsLPX/ztCY4kGEbpfGdJh88HVTeq+UZvePNQ
	kNVSKoE9Zbg5NZd4zesEShJxHo=
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
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL autolearn=ham version=3.3.2 spammy=H*i:sk:21af49f, H*f:sk:21af49f, H*UA:Outlook, H*x:Outlook
X-HELO: outmail148111.authsmtp.net
From: "David Allsopp" <dra27@cantab.net>
To: "'Marco Atzeri'" <marco.atzeri@gmail.com>, <cygwin@cygwin.com>
References: <005c01d1a6e2$30270ba0$907522e0$@metastack.com> <CACoZoo1LObZ0zu9X5O6dV4cO4jN+GO28bdRbuDkTMdaKHXpVbQ@mail.gmail.com> <000101d1a76d$c37c6b80$4a754280$@metastack.com> <967954968.20160506172040@yandex.ru> <006301d1a834$6ccd1380$46673a80$@cantab.net> <6e1f2ba2-0c8e-4659-4c5a-d748e90c1ced@lysator.liu.se> <8d8fe966-caeb-491c-32e7-fc48ccd56d74@gmail.com> <008f01d1aa0a$6b163f30$4142bd90$@cantab.net> <21af49f2-f685-828c-6bd4-8d734eedf378@gmail.com>
In-Reply-To: <21af49f2-f685-828c-6bd4-8d734eedf378@gmail.com>
Subject: RE: Formatting command line arguments when starting a Cygwin process from a native process
Date: Mon, 9 May 2016 17:14:29 +0100
Message-ID: <009001d1aa0d$de667b50$9b3371f0$@cantab.net>
MIME-Version: 1.0
Content-Type: text/plain;	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Server-Quench: 1d4c53f4-1601-11e6-bcde-0015176ca198
X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse
X-AuthRoute: OCd1ZAARAlZZVg1A VQsPBSlcQA9jIBBQ FxoeKRdbOF4EFV4Q JB4LaX9aIRpGHQgH E2cMUVVQWl5zF2F0 aBRQbQBDYEtMQQRr VFdLR01TWkBsCGt0 YBtjUhh3dgFHNnh4 ZUIsXyRfD0F5I0Jg Q0hUFHAHZDJmdTJM BBVFdwNVdQJNeEwU a1l3GhF4a3VxOTg9 FhMvPjY+dT5YLSFc RA1FKVMUTA4CBDEh Qh0EAS5nAk0IQW0o MxU8Nl8aEw4Yem4j PkQgXxoAKRgZBxZF V09XByoRLhEHTjYq Ew4SRVQZGzBGWk8W
X-Authentic-SMTP: 61633634383431.1038:706
X-AuthFastPath: 0 (Was 255)
X-AuthSMTP-Origin: 213.105.212.114/25
X-AuthVirus-Status: No virus detected - but ensure you scan with your own anti-virus system.
X-IsSubscribed: yes

Marco Atzeri wrote:
> On 09/05/2016 17:49, David Allsopp wrote:
> > Marco Atzeri wrote:
> >>
> >> Ultimate overview of MS escape howto :
> >>
> >> https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04
> >> /23/e veryone-quotes-command-line-arguments-the-wrong-way/
> >
> > This is a great article (which I'd not come across before), but this
> > relates to Microsoft's mechanisms for quoting which aren't applicable
> > here - it's definitely the Cygwin DLL which does it!
> >
> >
> > David
> >
> 
> Hi David,

Hi!

> I am puzzled, I had the impression you asked:
> "I am trying to work out the precise details for character escaping when
> starting a Cygwin process from a native (i.e. non-Cygwin) Windows
> process."
> 
> So the exec should be on "Windows process" side, why inside the Cygwin DLL
> ?

In Windows, there is no "exec" - the equivalent functions in Microsoft's C
runtime are themselves emulations boiling down to a CreateProcess call
(unlike on Unix, where the exec family are actual system calls). That
CreateProcess call takes exactly a single string for the entire command line
which the Cygwin DLL then has to convert to argc/argv in order to call the
main function in the Cygwin program started (Microsoft's C runtime has to do
the same thing which is part of what that blog explains). Any sane native
Windows program will use (or be compliant with) CommandLineToArgvW, but no
program has to do it that on Windows (indeed, Cygwin takes "advantage" of
this to do its own thing).

I have total control of my native call to CreateProcess, so it's definitely
about working out exactly what Cygwin does with the command line. AFAICT,
when a Cygwin program execs another Cygwin program, they actually
communicate argc and argv via memory, rather than through the process
invocation (although I'm really not sure that I've interpreted that
correctly) which is why this doesn't come up in pure Cygwin-land.

I think I'm there, it's just not as clean (or documented) as might be nice!


David


--
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

