Berkely unix (4.2) tty ioctl question

Warren Montgomery warren at ihnss.UUCP
Mon Sep 24 23:37:43 AEST 1984


Thanks to all who responded to my questions on 4.2BSD tty ioctls

There are two imperfect solutions to the problem of how to wait for
output to drain before getting an ioctl to take place:

1)	Use TIOCSETP with the current parameters, and then set
	whatever you want.  This works fine, but flushes the input
	queue, which was unacceptable in my application.

2)	Use the poorly documented TIOCOUTQ ioctl to find the current
	size of the output queue and busy wait while it goes to
	zero.  You can busy wait with less resource consumption by
	delaying for an amount of time computed to allow the queue
	to drain at full speed at the current baud rate.  The most
	convenient way to do this is using select() with only the
	timeout value to do the waiting.
	
A couple of people suggested using the select call directly, with
the tty as one of the write file descriptors to wait for, but as
other pointed out this does not work, since select waits only until
the driver will accept more characters for output, not until output
has drained.

These seem to be the best options available.  It's a shame that the
Berkeley tty ioctls aren't more orthogonal, allowing independent
control of more of the capabilities, but that's life!

-- 

	Warren Montgomery
	ihnss!warren
	IH (8-367) x2494



More information about the Comp.unix mailing list