cbreak problem

cnrdean at ucbtopaz.BERKELEY.EDU cnrdean at ucbtopaz.BERKELEY.EDU
Thu Feb 6 08:26:39 AEST 1986


I am porting a program on to a Berkeley 4.2  Vax, and I'm having
trouble with my cbreak mode:  I need to process characters as they come
in.  My problem is that when I try to print the characters, they don't
get printed at the point that I request them to, unless I put a fflush
in.  I thought that when I was in cbreak mode, putchar() would show up
immediately, without fflushing.

Can you help?  I've read TTY(4), and tried fooling with some of the
flushing mechanisms in there, to no avail.

Following is an example of my code:

#include <sgtty.h>
. . .
char c;
struct sgttyb
cbrmode,			/* Controlling tty cbreak mode */
cookedmode;			/* Controlling tty cooked mode */
. . .
gtty(0,&cbrmode);
cbrmode.sg_flags |= (CBREAK);
cbrmode.sg_flags &= ~(ECHO|XTABS|CRMOD);
stty(0,&cbrmode);			/* Put tty in cbreak mode */
. . .
read(0,&c,1);		/* Get a character */
c =  c & 0177;
putchar(c);



More information about the Comp.unix.wizards mailing list