This is the mail archive of the
mailing list for the Cygwin project.
Re: Question about Cygwin process behaviour and bash interactivemode
- From: Igor Pechtchanski <pechtcha at cs dot nyu dot edu>
- To: cygwin at cygwin dot com
- Date: Sat, 14 Sep 2002 13:52:42 -0400 (EDT)
- Subject: Re: Question about Cygwin process behaviour and bash interactivemode
- Reply-to: cygwin at cygwin dot com
On Sat, 14 Sep 2002, Chris January wrote:
> 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?
My guess is that isatty() behaves differently depending on whether we have
a first-level or a second-level invocation of cmd.exe...
Quoting from the bash-2.05b-3 source (shell.c:462):
/* First, let the outside world know about our interactive status.
A shell is interactive if the `-i' flag was given, or if all of
the following conditions are met:
no -c command
no arguments remaining or the -s flag given
standard input is a terminal
standard output is a terminal
Refer to Posix.2, the description of the `sh' utility. */
if (forced_interactive || /* -i flag */
(!local_pending_command && /* No -c command and ... */
wordexp_only == 0 && /* No --wordexp and ... */
((arg_index == argc) || /* no remaining args or... */
read_from_stdin) && /* -s flag with args, and */
isatty (fileno (stdin)) && /* Input is a terminal and */
isatty (fileno (stdout)))) /* output is a terminal. */
The Posix.2 standard can be found here:
Quoting from isatty source (newlib/libc/posix/isatty.c:12):
if (fstat (fd, &buf) < 0)
if (S_ISCHR (buf.st_mode))
So, isatty() simply checks if the file descriptor given is a character
device or not. I'm not sure quite how this works with windows programs
started from bash.
Hope this helps.
> chris@AVACADO ~
I'm just curious, is "avocado" in your hostname misspelled on purpose? ;-)
|\ _,,,---,,_ email@example.com
ZZZzz /,`.-'`' -. ;-;;,_ firstname.lastname@example.org
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
It took the computational power of three Commodore 64s to fly to the moon.
It takes a 486 to run Windows 95. Something is wrong here. -- SC sig file
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html