Redirection to stderr

Eliot Moss moss@cs.umass.edu
Mon Jul 10 16:32:00 GMT 2017


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



More information about the Cygwin mailing list