delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/02/24/09:47:32

X-Recipient: archive-cygwin AT delorie DOT 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:mime-version:references:in-reply-to:from:date
:message-id:subject:to:content-type; q=dns; s=default; b=NVjpxjC
oQLasHjPHWx1LepY5ntNgx/0eNfl/JF/+iyU6XxQFPHdkIjB2Ndx9YYu8uSb5Q1z
rU6phhv6Ig0aKZwePu776Yh/6GK1HUifJXeBadQeWBYi9Nquhp7kQxXtTZjAJfkB
H4V456BUd4xPfpfoho6s+3tPll5ywhzHOCs4=
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:mime-version:references:in-reply-to:from:date
:message-id:subject:to:content-type; s=default; bh=iv99io2ISenWK
ZKK/LkBuMc57hY=; b=Tn6xSlRJZGUa15y4TX9I5a0daveNBXucq+aPV9a1ndnv2
rtDHXfLP9O3cYUSieY5YQvsKtkYloFwWc1DeOZVhEq++vYkWlnKKtlejJ/JalbtL
MLcxN7slGP9e3qRZDLjcHOlJGusECJpEVo9O3k2vFJ+8GLdJY/dmNX/fkBXfGw=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,UNSUBSCRIBE_BODY autolearn=no version=3.3.1 spammy=inherited, studio, ship, Studio
X-HELO: mail-ed1-f46.google.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=WLu5AFs2bQC/KkhpefEbams2YN+hBFQJHdk1g5/fgh8=; b=ncECB4TEY5IevfDZal+s26zq9fqxyKCtTJOiVBN4ik8Hjq2+uW/2QNkSFkrF8X5od9 nkoIKiyVd/HhjMtVA/Br/+MLtIhNRNCzvpyHnjt0rtedFB5Y0JMZ9hDTHOTuk03aeUtr Eds2dcAV3l29EAscpNn8r4Y/RmmZ476H12Subh3GyDmsNia/EGRb5dwgj+Z3pEaieUUI EoZ/lejU+s/UfJ8gbZA0/m0M+CQLE48dur0MTyXC6pt++GOmhv9MmPvDR517uHIsJVje tNksUCqOddtEuBTguardBERy4YuxLb+36+Lb2nlVZNA17ShSPRuoMf5xsgMgIYpBcZ5w vXuQ==
MIME-Version: 1.0
References: <CAJZe6MDdZnE7BNZQWSHgaLo6sbx+9KVhG+wKfcruh_exPaZFLQ AT mail DOT gmail DOT com> <20200131072536 DOT da46ccf9cb52b1afdefa2a9a AT nifty DOT ne DOT jp> <CAJZe6MDszFgBvjhga_WCaTKACk3GWbP-jBGsZ3dd-4vMrQ93iQ AT mail DOT gmail DOT com> <CAJZe6MBh5mDzb8JDG+tG7wCq9RdU4CcxF01hNW7Qrj4JqjTZNg AT mail DOT gmail DOT com> <20200219044302 DOT bd24ffa7af1f159c67583600 AT nifty DOT ne DOT jp> <CAJZe6MBrUcn7Z=gJhwBh-x+pQ_KkaDvqSpRJn6zQgrg0m6zshw AT mail DOT gmail DOT com> <20200221100121 DOT 44625484e94eef069f9ff3d8 AT nifty DOT ne DOT jp>
In-Reply-To: <20200221100121.44625484e94eef069f9ff3d8@nifty.ne.jp>
From: Edward Lam <triplequadsupport AT gmail DOT com>
Date: Mon, 24 Feb 2020 09:46:15 -0500
Message-ID: <CAJZe6MCnEbdZEup2PBm2MgvpJZKcmgWV5dy4tD3kVFnxBFOPEw@mail.gmail.com>
Subject: Re: Pipes bug when spawning non-cygwin processes
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes

Hi,

Thank you for your reply.

On Thu, Feb 20, 2020 at 8:01 PM Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
wrote:

> Thanks for the test case. Indeed, this works upto cygwin 3.0.7,
> and does not work in cygwin 3.1.0 or later.
>
> However, I wonder what platform is your program for. This test
> case does not work also in native windows command prompt.
> Your test case works only in old cygwin pty.
>

I have a native graphical Windows application that relied on cygwin/mintty
providing stdout so that my printf's work.

I would contend that there's no reason for cygwin/mintty to work the same
as the native windows command prompt because the behaviour there is for it
to detach the child process. This is not the case when we run a graphical
process in a cygwin/mintty shell. The old behaviour was much welcome
because it allowed graphical applications that did not detach from the
console work just like on Linux.

I should note that there is also the odd behaviour that the child process
is created with an inherited stderr handle but when I try to write to it,
it doesn't show up anywhere. On the native windows command prompt, the
child process isn't even created with the inherit handles flag enabled.

If you want to make a program which works in cygwin pty, you
> can use cygwin g++ like:
> g++ -mwindows pipes.cpp -o pipes
> The binary built by above command works in cygwin pty, but does
> not work in cygwin console (cygwin in command prompt) even with
> cygwin 3.0.7.
>

This might not have worked in cygwin 3.0.07 because it's missing a
freopen("CONOUT$", "w", stdout). I had omitted this in my minimal test case
because I found that this was unnecessary when I built with Visual Studio.

If you want to make a program which works with windows console,
> you should change the code like:
>
> INT WinMain(HINSTANCE, HINSTANCE, PSTR, INT)
> {
>     if (!AttachConsole(ATTACH_PARENT_PROCESS)) AllocConsole();
>     freopen("CONOUT$", "w", stdout);
>     printf("This message used to show up in mintty cygwin v.2.11.2 shell!
> or from ssh session\n");
>     return 0;
> }
>

Ah, I did not now about AttachConsole(ATTACH_PARENT_PROCESS).

The application that I ship out to my users cannot force the requirement of
having cygwin, nor is compiling with cygwin g++ an option. Is there some
way to have a non-cygwin app detect the presence of cygwin pty so that it
can behave differently? When the native command prompt detaches the child
process, the child process should not really write to the parent's console
and should allocate its own instead.

Thanks again,
-Edward

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019