rxvt isatty

PCJohn peciva@fit.vutbr.cz
Wed Mar 21 16:15:00 GMT 2007


Hi all,

I found the possible solution. I have just a question whether Cygwin's 
pty's behaviour is changed often and whether it should work throughout 
the many past releases of Cygwin.

On MSVC, it is possible to use GetNamedPipeInfo() and 
GetNamedPipeHandleState() and based on their behaviour, to distinguish 
between all different possibilities:

//
// results from rxvt:
//
// ./pipetest
//   stdin: SERVER_END pipe, name: John
//
// ./pipetest <file.txt
//   stdin: pipe functions failed - it is a standard file
//
// echo 123 | ./pipetest
//   stdin: SERVER_END pipe, without name
//
//
// results from Windows console:
//
// pipetest
//   stdin: no pipes
//
// pipetest <file.txt
//   stdin: no pipes
//
// echo 123 | ./pipetest
//   stdin: SERVER_END pipe, without name
//

Note for others interested: It is necessary to pass NULL params to 
GetNamedPipeHandleState in different cases, otherwise the function 
fails. I found my MSDN doc not much clear at this point.


Thanks for comments,
John



On Mon, Mar 19, 2007 at 05:37:18PM +0100, PCJohn wrote:
>I was trying to port ivTools
>(http://merlin.fit.vutbr.cz/wiki/index.php?title=Open_Inventor_Tools) to
> work smoothly with Cygwin. It works on Cygwin console without problems
>($CYGWIN=notty), but rxvt causes all the utilities to freeze.
>
>I found the problem: utilities are testing stdin by isatty. If
>isatty==false, stdin is used for reading the data. If isatty returns
>true, there is really bad idea to wait that user will feed the program
>by complex 3D geometry, and utility is started without reading stdin.
>
>If rxvt is used, isatty returns always false and application does not
>work as expected. I realized that some advanced console functionality is
>provided with rxvt (pty, pipes) to overcome the limitations of windows
>console. My question: Can I find out in if the application is running
>interactive or not? If it was started like:
>app_name.exe < in.txt
>echo data | app_name.exe
>or
>app_name.exe
>
>Another minor question: How to use the advanced functionalities provided
>by pty and pipes? Just get_osfhandle(fileno(stdin)), ReadFile, and
>WriteFile?

Given that you're talking about things like isatty returning false,
get_osfhandle, ReadFile, and WriteFile, I surmise that you're trying to
run a non-Cygwin-based program under rxvt.  None of those are Linux/UNIX
functions and, if you use them in a Cygwin program there are no guarantees
that you will be able to use any of Cygwin's UNIX/Linux-like features.

Cygwin's ptys are entirely an invention of Cygwin so, to avail yourself
of ptys you can't build the application with MSVC or gcc -mno-cygwin or
MinGW gcc.  You really need to build your program so that it uses the
cygwin dll, i.e., it has to be compiled with the normal Cygwin gcc.


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list