raw/cooked single char i/o

guy at rlgvax.UUCP guy at rlgvax.UUCP
Sat Jun 11 14:59:55 AEST 1983


The difference between RAW and CBREAK mode, in 25 words or less:

RAW mode means

	8-bit data path, with no parity checking
	no special character interpretation whatsoever
	wakeup on every character is possible
	no special output processing whatsoever

CBREAK mode means

	7-bit data path, with whatever parity checking is enabled
	"line processing" (erase, kill, EOF, special EOL, and retype on
		4.1BSD) is disabled, BUT the interrupt and quit
		characters are enabled (as are the other signalling characters
		on 4.1BSD); furthermore, XON/XOFF processing is also active
	wakeup on every character is possible
	no change to the output processing from COOKED mode whatsoever

Programs which run interactively on a keystroke basis should NEVER run in
RAW mode, only CBREAK mode.  CBREAK mode is intended for exactly those kinds
of programs; RAW mode is SOLELY intended for binary data transmission (like
UUCP).  For USG UNIX, read ~ICANON mode for CBREAK mode and read "some very
complicated set of bits turned on and off" for RAW mode.

"curses" has the "functions" (actually macros, at least in 4.1BSD) "crmode"
and "nocrmode", which function analogously to "raw" and "noraw" except that
they put the terminal in CBREAK mode rather than RAW mode.

I've noticed several references to RAW mode being what screen editors and the
like run in.  This is either due to the fact that RAW mode was all you had
on V6, or due to people simply not being aware of CBREAK mode, or due to
people not being aware how obnoxious RAW mode is for interaction with a
human at a terminal.  In USG UNIX, you CAN turn on 8-bit characters without
turning off the interrupt characters and XON/XOFF, but your terminal better
use the 8th bit for information rather than parity.

		Guy Harris
		RLG Corporation
		{seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy



More information about the Comp.unix.wizards mailing list