delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/09/14/15:29:42

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
X-WM-Posted-At: avacado.atomice.net; Sat, 14 Sep 02 20:29:35 +0100
From: "Chris January" <chris AT atomice DOT net>
To: "Cygwin AT Cygwin DOT Com" <cygwin AT cygwin DOT com>
Subject: RE: Question about Cygwin process behaviour and bash interactive mode
Date: Sat, 14 Sep 2002 20:29:35 +0100
Message-ID: <LPEHIHGCJOAIPFLADJAHAELMCMAA.chris@atomice.net>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
In-Reply-To: <LPEHIHGCJOAIPFLADJAHKELHCMAA.chris@atomice.net>
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:

I'm running the following program:

#include <windows.h>
#include <stdio.h>

int main (void)
{
    HANDLE handle;
    DWORD dwFileType;
    const char *pszFileType;
    printf ("GetStdHandle (STD_INPUT_HANDLE) = %p\n", handle = GetStdHandle
(STD_INPUT_HANDLE));
    dwFileType = GetFileType (handle);
    switch (dwFileType) {
        case FILE_TYPE_UNKNOWN:
            pszFileType = "FILE_TYPE_UNKNOWN";
            break;
        case FILE_TYPE_DISK:
            pszFileType = "FILE_TYPE_DISK";
            break;
        case FILE_TYPE_CHAR:
            pszFileType = "FILE_TYPE_CHAR";
            break;
        case FILE_TYPE_PIPE:
            pszFileType = "FILE_TYPE_PIPE";
            break;
    }
    printf ("GetFileType (%p) = %s\n", handle, pszFileType);
}

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.

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019