From: utzoo!decvax!watmath!atbowler Newsgroups: net.unix-wizards Title: Re: STDIO on TTYs: Discussion and Request for Fix Article-I.D.: watmath.2871 Posted: Tue Jun 29 15:52:05 1982 Received: Thu Jul 1 01:06:58 1982 References: brl-bmd.235 Having worked on I/O packages for several non-Unix environments, I would like to share some observations. 1) Buffering pays off. You can do a lot of computation in the time it takes the system to field 1 system call. 2) It is not a question of flushing stdout and stderr on a read from stdin, but of flushing the corresponding output buffer(s) when reading from a terminal, wheither it was opened as unit 1 or 9. To do this you need to keep track of which units are TTY's, and which units are the same TTY. Xerox's CP-5 used to supply a system call to test this, but a little enginuity at open time will usually suffice. 3) You should arrange that different output units that share a tty, share a buffer. I.e. stout and stderr normally would point at the same buffer. That way messages appear in the order they are issued in the program and not in the flush order. 4) The output buffer is flushed under the following situtations and standard subroutines should be supplied for this 1) the output buffer is full 2) the buffer is being closed (usually wrapup) 3) a read was issued from a corresponding read unit 4) the program goes to sleep (sleep for n seconds or sleep until time.. whatever the system has) This is a situation where you supply a standard subroutine and advertize it, instead of the one that does just the system call 5) The program calls another program and waits for it. i.e. i.e. the function 'system'