[net.unix] How does litout work

ron@oscvax.UUCP (Ron Janzen) (11/25/85)

I remember a few months ago there was some discussion on how
the LITOUT mode that is available in the tty driver worked.
At the time I paid only marginal attention to the discussion
but I now need to now how it works. I seem to recall that LITOUT
was slightly buggy and you had to go thru some special contortions
to get it to work properly. For those who do not know LITOUT supposedly
provides a full 8-bit path for output (like RAW) but still maintains
flow control (like CBREAK). If someone could send me the magical incantations
to make LITOUT work properly I would be forever grateful. We are
running bsd4.1 on a Vax750.

Thanks in advance,
-- 
Ron Janzen
Ontario Science Centre, Toronto
...!{allegra,ihnp4,linus,decvax}!utzoo!oscvax!ron

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (11/29/85)

>  I seem to recall that LITOUT
> was slightly buggy and you had to go thru some special contortions
> to get it to work properly.

The word was that LITOUT would not stick unless you set it a
second time.  I don't know why this would happen; sure seems
strange.  But we have had similar problems with other aspects
of the tty handler (such as input flushing occurring AFTER
the ioctl has returned), at least on UTX-32, so maybe it can
really happen.  Yet another mystery..

chris@umcp-cs.UUCP (Chris Torek) (11/29/85)

In article <170@brl-tgr.ARPA> gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) writes:

>> I seem to recall that LITOUT was slightly buggy and you had to go
>> thru some special contortions to get it to work properly.

> The word was that LITOUT would not stick unless you set it a
> second time.

No:  The problem was that the device drivers did not call the
`param' routine when changing the local mode word.  Only TIOCSETP
and TIOCSETN would force a call.  With one of these buggy drivers,
to set LITOUT mode, use something like the routine below.

#include <ioctl.h>

/*
 * Set LITOUT mode on the tty line corresponding to the
 * descriptor `fd'.  Since you may not have installed the
 * (trivial) fix in your kernel for the bug, we use a
 * kludge.
 *
 * The fix:  In each tty device driver, find the code for
 * ioctl (e.g., `dhioctl' or `dzioctl').  There will be a
 * bit of code that looks like this:
 *
 *	if (cmd == TIOCSETP || cmd == TIOCSETN)
 *
 * Change the `if' statement to read:
 *
 *	if (cmd == TIOCSETP || cmd == TIOCSETN || cmd == TIOCLSET ||
 *	    cmd == TIOCLBIS || cmd == TIOCLBIC)
 *
 */
set_litout_with_bug_workaround(fd)
	int fd;
{
	int litout = LITOUT;
	struct sgttyb sg;

	if (ioctl(fd, TIOCLBIS, &litout))
		return (-1);	/* probably not a tty line */
	/*
	 * Here is the workaround.
	 */
	if (ioctl(fd, TIOCGETP, &sg))
		return (-1);
	if (ioctl(fd, TIOCSETP, &sg))
		return (-1);
	return (0);
}
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu