Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 exptools 1/6/84; site ihnss.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!ihnss!warren From: warren@ihnss.UUCP (Warren Montgomery) Newsgroups: net.unix Subject: Re: Berkely unix (4.2) tty ioctl question Message-ID: <2242@ihnss.UUCP> Date: Mon, 24-Sep-84 09:37:43 EDT Article-I.D.: ihnss.2242 Posted: Mon Sep 24 09:37:43 1984 Date-Received: Wed, 26-Sep-84 08:17:16 EDT References: <2233@ihnss.UUCP> <4791@brl-tgr.ARPA> Organization: AT&T Bell Labs, Naperville, IL Lines: 33 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