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:reply-to:subject:references:to:from:message-id
	:date:mime-version:in-reply-to:content-type
	:content-transfer-encoding; q=dns; s=default; b=hMb51mYNQSreCOdI
	GLy48X6m9stgogsjFgbXgCv7JA/uStxY6NnoR0dyXWATO3FLxh+ep90Fb7/koUOq
	ffcPLQSNcY6JTfT6nNnuThqOwr8BGGTVOKtLkk1C61APQGFA15hv5jLf67lI4/DU
	OnL/BzKiHdRSxduaRTOPnqIfIQw=
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:reply-to:subject:references:to:from:message-id
	:date:mime-version:in-reply-to:content-type
	:content-transfer-encoding; s=default; bh=hR3Pdv6CMwgm+dIxj821rL
	UOe80=; b=awLp3gqYiGryUguoMZ37vtQKumhvz4A5cNzl1WmZZ9FJeJtEy4aim1
	4CupV23jCqwxGPFDWsHq+ne9+juE1fUonMN53xJU4gaz2z5o3cegPfJvKwJw+xb9
	lxzHTFaN+N8YLgzAK/0rBNPvQzmiD6MXExdsCgfGR9XieVnYF/Upc=
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.5 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=schneider, Schneider, Repin, andrey
X-HELO: mailsrv.cs.umass.edu
Reply-To: moss@cs.umass.edu
Subject: Re: Redirection to stderr
References: <baa3a4f84968dd6aa9869d2c9f58197f.squirrel@mail.schneiderp.de> <b4de479d-882e-4e61-2916-1b54f318d76c@gmail.com> <ec89b6011aad4b68a294d3f1d462d40b.squirrel@mail.schneiderp.de> <1761324316.20170710155536@yandex.ru> <581103da7715b704f454365749ab3b00.squirrel@mail.schneiderp.de>
To: cygwin@cygwin.com
From: Eliot Moss <moss@cs.umass.edu>
Message-ID: <4020dbe3-bfb1-e0fc-22b2-0ab4e1330975@cs.umass.edu>
Date: Mon, 10 Jul 2017 12:32:45 -0400
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
MIME-Version: 1.0
In-Reply-To: <581103da7715b704f454365749ab3b00.squirrel@mail.schneiderp.de>
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes

On 7/10/2017 9:41 AM, Peter Schneider wrote:
> On Mon, July 10, 2017 14:55, Andrey Repin wrote:
>> Greetings, cygwin-mailinglist!
>>
>>> On Mon, July 10, 2017 12:33, Marco Atzeri wrote:
>>>>
>>>> On 10/07/2017 11:06, cygwin-mailinglist wrote:
>>> [...]
>>>>> Rationale aside, it is a bug, isn't it?
>>>>
>>>> I guess a side effect of a lost race.
>>
>>> Which race, exactly?
>>
>> echo aaa > a
>> cat a > a
>
> The problem with "cat a > a" is entirely unrelated to "some-cmd
> 2>/dev/stderr". (Apart from /dev/stderr not being a regular file, some-cmd
> does not receive a path argument which it tries to open, the way "cat a"
> does.)

Understanding what is happening would require figuring out which process
opens /dev/stderr and when.  However, there is another approach that might
get at what you want: /proc/nnnn/fd/2 gives access to file descriptor 2
(standard error) of process number nnnn.  If you can get the right pid,
and you have access rights, then you can open that.  Here the PPID
environment variable may be useful.

Which stderr is it you're hoping the output will go to?

Regards - EM

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

