Mail Archives: cygwin/2002/09/14/15:29:42
> 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 -