From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5007 invoked by alias); 5 Dec 2007 10:11:20 -0000 Received: (qmail 4994 invoked by uid 22791); 5 Dec 2007 10:11:18 -0000 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Wed, 05 Dec 2007 10:11:12 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 819D36D4805; Wed, 5 Dec 2007 11:11:09 +0100 (CET) Date: Wed, 05 Dec 2007 12:17:00 -0000 From: Corinna Vinschen To: gdb-patches@sourceware.org Subject: Re: [RFC] gdb/testsuite/gdb.base/fileio.exp patch for cygwin Message-ID: <20071205101109.GA31968@calimero.vinschen.de> Reply-To: gdb-patches@sourceware.org Mail-Followup-To: gdb-patches@sourceware.org References: <000101c83593$89c0fcd0$9d42f670$@u-strasbg.fr> <4755E78F.7000301@portugalmail.pt> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4755E78F.7000301@portugalmail.pt> User-Agent: Mutt/1.5.16 (2007-06-09) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-12/txt/msg00079.txt.bz2 On Dec 4 23:49, Pedro Alves wrote: > #include > #include > > int main () > { > printf ("isatty 0 = %d\n", isatty (0)); > printf ("isatty 1 = %d\n", isatty (1)); > printf ("isatty 2 = %d\n", isatty (2)); > return 0; > } > [...] > This GDB was configured as "i686-pc-cygwin"... > (gdb) r > Starting program: /home/pedro/isatty/main.exe > isatty 0 = 0 > isatty 1 = 0 > isatty 2 = 0 > [...] > I don't know enough of the Cygwin tty support, > but I would expect that if gdb had a (Windows) console > attached (bash started from cmd.exe, not the xterm or rxvt), > the inferior would inherit it, and the runtime would arrange > for the isatty to be true, but that doesn't seem to hold. > Neither CYGWIN=tty nor 'set new-group 0' seemed to help. > This probably has something to do with starting the inferior > with CreateProcess in win32-nat.c:win32_create_inferior. Right. The problem occurs when running a session in a pseudo tty like when starting GDB in a ssh session or when you set CYGWIN=tty before starting the first Cygwin process (the shell, usually) in a Windows console window. Pseudo ttys are implemented in Cygwin using pipes. When you start a Cygwin application with fork/exec, the knowledge about this pipes (being a pseudo tty) is inherited by the child process by means of the fork/ exec magic. If you start a Cygwin process from another application using native Windows functions (CreateProcess, etc), the whole fork/exec magic is missing, apparently. One result is that the child process has to figure out what the stdin/out/err streams are, using native Windows functions. Since native Windows functions have no idea what a pseudo tty is, the information returned is that stdio streams are connected to pipes. So the child thinks its stdio streams are just pipes and pipes are not ttys, apparently. Corinna -- Corinna Vinschen Cygwin Project Co-Leader Red Hat