Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-WM-Posted-At: avacado.atomice.net; Sat, 14 Sep 02 20:36:08 +0100 From: "Chris January" To: "Cygwin AT Cygwin DOT Com" Subject: RE: Question about Cygwin process behaviour and bash interactive mode Date: Sat, 14 Sep 2002 20:36:08 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Importance: Normal > > If I launch a Windows command shell (cmd.exe) from, e.g. a Window > > shortcut, > > and then run bash from that shell, bash starts interactive mode. > > If I launch a Cygwin bash shell from, e.g. cygwin.bat, then run cmd from > > that shell (I type cmd), a Windows command shell starts. If I > > then run bash > > from that command shell, bash starts in non-interactive mode. > > > > Can anyone explain this behaviour and why bash starts in > > interactive mode in > > one case, and non-interactive mode in the other, even though > both times it > > is launched from cmd.exe? > The reason bash starts in interactive mode is because the > STD_INPUT_HANDLE and STD_OUPUT_HANDLE are pipes. See below: > When run from cmd.exe: > GetStdHandle (STD_INPUT_HANDLE) = 0xf > GetFileType (0xf) = FILE_TYPE_CHAR > > When run from bash: > GetStdHandle (STD_INPUT_HANDLE) = 0x6f4 > GetFileType (0x6f4) = FILE_TYPE_PIPE > > I'm really at a loss to explain this! I'd be grateful if someone > else could give some insight. Upon further examination it would appear this is a bug in the tty handling code. First of all, this behaviour is only observed when the tty flag is set in the CYGWIN environment variable. It seems that the tty code uses pipes for some reason or another (see tty::make_pipes). However, if a non-cygwin program is launched, which then launches another cygwin program, the second cygwin program doesn't detect that it's stdin and stdout pipes were created by the tty code (and hence should be handled by fhandler_tty). I don't really understand this code well enough to fix this - perhaps someone else could take a look? Chris -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/