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:

> 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?


Unsubscribe info:
Bug reporting:

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