Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.programmer Subject: Re: raw mode vs cooked mode Message-ID: <6303@auspex.auspex.com> Date: 26 Feb 91 19:19:19 GMT References: <505sis-c@massey.ac.nz> <482@bria> Organization: Auspex Systems, Santa Clara Lines: 37 >>I would like to write a program which will get characters from the terminal >>in "raw" mode. The default is "cooked" mode. Can someone point me in the >>right direction? I am using a Sun Workstation running UNIX 4.2 BSD. > >This should be in a FAQ somewhere. If your system groks termio, then >here is what you could have: It's what he should have *if*, by "raw mode", he means "a mode in which the parity and bits-per-character are the same as 'normal', characters are made available to a program reading from the device as they're typed, and the only characters that are treated specially are the XON and XOFF characters." That happens to be what a lot of people who want some flavor of "less cooked" mode want. Others may want a raw 8-bit data path with *no* characters treated specially (for, say, binary data transfer), or may want the interrupt characters to be treated specially. I have no idea what the person who asked the question wanted; they didn't give any details, they just asked for "raw" mode. The "old" tty driver (V7, and its pre-4.3-reno BSD descendant) had RAW for the raw 8-bit data path, and CBREAK for "make characters available as they're typed, and don't treat the erase/kill//etc characters specially." To turn of the interrupt characters as well, you could set them to '\377', as in CBREAK mode input was stripped to 7 bits (unless you turned PASS8 on, in 4.3BSD or later). (RAW also turned off any special character handling on *output*.) The "new" tty driver (S3, S5, 4.3-reno and successors, POSIX) does a better job of specifying those modes; you have much finer control over what the driver does. (Also, since they said the Sun was running "UNIX 4.2 BSD", I suspect it was running a SunOS release prior to 4.0, which means that, unless he was working in the S5 environment, the system *doesn't* grok "termio" - it has the "old" tty driver.)