Need help w/unbuff'd input.

Steve Summit scs at
Tue Jun 12 10:11:05 AEST 1990

This topic is discussed in the frequently-asked questions list
(question 43 in the June posting).

In article <612 at> hannum at (Charles Hannum) writes:
>What you need to do is set 'cbreak' mode on your tty.

This is true only under some versions of Unix.  It is not true
under other versions of Unix (i.e. under System V and POSIX and
related systems, including, I am told, 4.4bsd, you play with
"min" and "time" parameters to set up various forms of "non-
canonical mode input processing") nor is it generally true under
non-Unix systems.

>    ioctl(stdin, TIOCGETP, &otty);

stdin is usually a FILE *, not the int which ioctl expects.
You could use fileno(stdin).  Note that you should really make
sure the ioctl succeeds -- it will not, for instance, in the
common case when your program has its input redirected from a
file.  (Chris did note later in his posting that "this only works
on ttys.")

                                            Steve Summit
                                            scs at

>  (tcsh sets the mode back automatically...

A questionable feature, since (at least on the version of tcsh
here, which may be out of date) the stty command cannot then be
used to adjust terminal driver parameters you do want to change
permanently.  I'm sure there have been flame wars about this
topic before; I probably shouldn't mention it.

More information about the Comp.lang.c mailing list