TTY Problem
The Gnu Emacs and Cygwin tty problem has been haunting me since
I have started using them the first day. I did not understand
the cause of the problem at that time. After sufficient researches,
I think I have now understood the cause of it, but I have no solution to it.
Hopefully someone brilliant can solve the problem for me.
TTY Problem on Gnu Emacs
For Gnu Emacs running in Windows, if a shell is invoked
(regardless of cmd.exe shell, emacs eshell or cygwin bash shell),
the shell is not run under a tty terminal.
This can be verified by invoking the tty.exe command distributed with
cygwin. The output from the tty.exe command simply says "not a tty".
(For Gnu Emacs running in Unix, tty command says "/dev/ttyN".)
If an application is not invoked within a tty terminal, usually the
application assumes that its output is redirected to a file. The application
will buffer the output. This means the output will not be flushed until
a sufficient amount of output has accumulated.
Considered the following simple buffer.c program.
#include <stdio.h>
int main(int argc, char** argv)
{
char buf[1000];
if( _isatty( _fileno( stdout ) ) )
printf( "stdout has not been redirected to a file\n" );
else
printf( "stdout has been redirected to a file\n");
printf("Hello World\n");
scanf("%s",buf);
return(0);
}
If you run the program under a DOS prompt console, the output will be
as follow (assuming xxxx is your input)
stdout has not been redirected to a file
Hello World
xxxxx
Unfortunately, if the program is run in a Gnu Emacs in Windows, since
the shell is not a tty terminal, the output
will be as follow
xxxxx
stdout has been redirected to a file
Hello World
TTY Problem on Cygwin rxvt
It is fortunate that the tty problem does not happen in Cygwin Bash shell
running in a Windows DOS prompt console. If a tty.exe command is invoked, it
says "/dev/conin".
However, if the Cygwin Bash shell is run in a Cygwin rxvt
terminal, the problem appears (assuming the buffer.c program is compiled
using Microsoft Visual C compiler or using Cygwin gcc with -mno-cygwin option).
If a tty.exe command is invoked, it
says "/dev/ttyN". This suggests that /dev/ttyN used by Cygwin is not recognized as
tty by Windows.
If the same buffer.c program is compiled using Cygwin gcc complier against
the cygwin.dll (gcc buffer.c), then the problem goes away.
This means Cygwin applications recognize /dev/ttyN as a valid terminal.
In short, all Cygwin applications work well in a rxvt terminal. All Windows
applications that do not involve user inputs work in a rxvt terminal as well.
The problem is with all Windows applications that require user inputs.
More information about this problem
Solutions
I do not know the solution. The workaround is to run Windows applications that
require user inputs in a Cygwin Bash shell in a Windows DOS Prompt console.
Let me know if you have found a solution.
|