Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!seismo!hao!hplabs!sri-unix!gwyn@brl-vld From: gwyn%brl-vld@sri-unix.UUCP Newsgroups: net.unix-wizards Subject: Re: stdio buffering considered harmful Message-ID: <3667@sri-arpa.UUCP> Date: Sun, 31-Jul-83 16:12:26 EDT Article-I.D.: sri-arpa.3667 Posted: Sun Jul 31 16:12:26 1983 Date-Received: Wed, 3-Aug-83 03:23:33 EDT Lines: 21 From: Doug Gwyn (VLD/VMB)There are two obvious choices to solve the problem of buffered output not appearing (i.e. being flushed out) before an input operation: (1) Write the program so it fflush()es relevant output before trying the read (this works with all versions of stdio and puts the decision where it really belongs, in the programmer's lap); (2) Write stdio itself so ALL output streams to terminals (and pipes) are flushed whenever input is attempted from ANY terminal (or pipe). There is no reason to handle stdin and stdout only, since that only helps in some cases but does not solve the general problem, if it is a problem. Personally I favor alternative (1). According to UNIX System V manuals Bell has adopted alternative (2) for terminals only, not pipes. Berkeley appears to have adopted (2) for stdout/stdio terminals only. I think programmers ought to learn to program carefully rather than rely on library code to make up for their sloppiness.