BSD ioctl question

Guy Harris guy at auspex.auspex.com
Thu Apr 11 04:12:05 AEST 1991


In article <DAVIS.91Apr9055635 at pacific.mps.ohio-state.edu>
davis at pacific.mps.ohio-state.edu  (John E. Davis) writes:
>  This is a BSD unix question.  I to read a character in RAW mode from, say,
>file descriptor 2.  Raw turns off all input/output processing.  However, I
>only want input processing turned off.  This is not the same as CBREAK.
>CBREAK still does input processing on the special characters ^Z (stop),
>^\ (quit), etc... which I want turned off.  So my question is this:  from
>within a C program how do I accomplish the above objective?

Well, it depends on what you do, and what you don't, want turned off. 
It also depends on what flavor of tty driver your OS has; you say "BSD
UNIX", but also say

>Note: I did RTFM but all it talked about was termio which our system
>does not have (although for some stupid reason the man pages think so).
>
>A related question (perhaps the same question): It seems that from the shell,
>I can type `stty -isig' to turn off input processing on the interrupt
>characters (^Z, etc..).

Given that you can type "stty -isig" from the shell, I'm skeptical of
your claim that your system doesn't have "termio", because ISIG is a
"termio"ism.  The explanations I can think of are:

	1) your system has "termios", but not "termio";

	2) your system has picked up some "termio"/"termios"isms, but
	   not others.

Precisely what OS are you running?  If it's a BSD release prior to
4.3-reno, I'm curious how it got "isig".  If it's 4.3-reno, it doesn't
have "termio", but it *does* have "termios".

>In BSD, how do I accomplish this with an ioctl?

Well, if your system really truly genuinely doesn't have "termio" *or*
"termios", the way you'd do it would be to go into CBREAK mode *and*
"disable" the interrupt characters - and the XON/XOFF characters, if you
want them "disabled" as well.  To "disable" them, set them to '\377'
using the TIOCGETC/TIOCSETC and TIOCGLTC/TIOCSLTC "ioctl"s; "disable" is
in quotes because that doesn't really disable them, it merely sets them
to a value unlikely to be seen (if you have 8-bit input turned on, they
are, at best, unlikely, not impossible; if you have 8-bit input turned
off, they are impossible).

If your system *does* have "termio" or "termios", then turn ISIG off to
disable all the interrupt characters (^C, ^Z, ^\), and turn IXON off to
disable the XON/XOFF characters.  You may also want to turn IEXTEN off,
as that may be necessary to disable the literal-next (^V) and
flush-output (^O) characters.

In article <11914 at dog.ee.lbl.gov> torek at elf.ee.lbl.gov (Chris Torek) writes:
>In general, you want CS8 (8 data bits), optional parity, ISIG and ICANON
>turned off, and OPOST turned on.

Well, I'm not sure he said he wanted 8-bit input....

>If you have a BSD system without `stty -isig' and without TIOCGETA etc.,
>you can fake 8-bit input without disabling output processing by setting
>LLITIN in the `local mode word',

Setting *what*?  "I see no LLITIN here."  Do you mean "PASS8"?



More information about the Comp.unix.programmer mailing list