How does litout work
Chris Torek
chris at umcp-cs.UUCP
Sat Nov 30 06:33:33 AEST 1985
In article <170 at brl-tgr.ARPA> gwyn at 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 at umcp-cs ARPA: chris at mimsy.umd.edu
More information about the Comp.unix
mailing list