This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Question about Cygwin process behaviour and bash interactive mode

> 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
    dwFileType = GetFileType (handle);
    switch (dwFileType) {
        case FILE_TYPE_UNKNOWN:
            pszFileType = "FILE_TYPE_UNKNOWN";
        case FILE_TYPE_DISK:
            pszFileType = "FILE_TYPE_DISK";
        case FILE_TYPE_CHAR:
            pszFileType = "FILE_TYPE_CHAR";
        case FILE_TYPE_PIPE:
            pszFileType = "FILE_TYPE_PIPE";
    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.


Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]