Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!hpda!hpsemc!bd
From: bd@hpsemc.UUCP (bob desinger)
Newsgroups: comp.sys.hp
Subject: Re: Does HP-UX have a CBREAK mode or equivalent?
Message-ID: <3530003@hpsemc.UUCP>
Date: Mon, 7-Dec-87 20:27:50 EST
Article-I.D.: hpsemc.3530003
Posted: Mon Dec  7 20:27:50 1987
Date-Received: Sun, 13-Dec-87 06:01:49 EST
References: <764@louie.udel.EDU>
Organization: HP SEMC, Cupertino, CA
Lines: 26

One way to get cbreak mode on HP-UX, like any System V implementation,
is to turn off canonical mode and tell read() to return after one
character.  The code fragment to do this goes something like:

	/* turn off canonical mode to get chars as they are typed */
	termio_settings.c_lflag &= ~ICANON;

	/* get 1 character at a time */
	termio_settings.c_cc[VMIN] = 1;
	/* termio_settings.c_cc[VTIME] is now irrelevant */

	/* set the terminal */
	if (ioctl(ttyfd, TCSETAF, termio_settings) == -1)
		perror("ioctl(TCSETAF)");

There is an excellent write-up of this technique in Marc Rochkind's
_Advanced_Unix_Programming_ (Prentice-Hall, 1985) available in
bookstores [and shipped with the HP 9000 Series 800 machines!].  See
page 86 starting with section 4.4.8, "Punctual Input," and the next
section, 4.5, entitled "Raw Terminal I/O."

bob desinger
HP Software Evaluation and Migration Center

P.S.	Has anyone seen his new book about terminal-handling?
	Is it as good as _Advanced_Unix_Programming_?