www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/11/25/23:45:17

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <4B0E07AC.3020505@cwilson.fastmail.fm>
Date: Wed, 25 Nov 2009 23:44:28 -0500
From: Charles Wilson <cygwin AT cwilson DOT fastmail DOT fm>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: run: requires CYGWIN=tty?
References: <4B0E0338 DOT 9000202 AT users DOT sourceforge DOT net>
In-Reply-To: <4B0E0338.9000202@users.sourceforge.net>
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

Yaakov (Cygwin/X) wrote:
> I came across this error with run when launched from the cmd prompt with
> an empty CYGWIN variable:
> 
>      1 [main] xterm 1248 dtable::stdio_init: couldn't make stderr
> distinct from stdout
> 
> If I set CYGWIN=tty then this does not occur.  Is this expected?

Not by me.  The relevant code in cygwin looks like this:

  /* STD_ERROR_HANDLE has been observed to be the same as
     STD_OUTPUT_HANDLE.  We need separate handles (e.g. using pipes
     to pass data from child to parent).  */
  /* CV 2008-10-17: Under debugger control, std fd's have been potentially
     initialized in dtable::get_debugger_info ().  In this case
     init_std_file_from_handle is a no-op, so, even if out == err we don't
     want to duplicate the handle since it will be unused. */
  if (out == err && (!being_debugged () || !not_open (2)))
    {
      /* Since this code is not invoked for forked tasks, we don't have
         to worry about the close-on-exec flag here.  */
      if (!DuplicateHandle (hMainProc, out, hMainProc, &err, 0, true,
                            DUPLICATE_SAME_ACCESS))
        {
          /* If that fails, do this as a fall back.  */
          err = out;
          system_printf ("couldn't make stderr distinct from stdout");
        }
    }

So, uhm...DuplicateHandle failed? That seems...strange.  Unless the
handle being duplicated is itself invalid.  (e.g. both out and err are
== INVALID_HANDLE (but then, !not_open(2) should catch that!)

Maybe somebody else will have an A-HA! moment, but without actually
debugging it this one has me confused.

--
Chuck

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