🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.bugs.4bsd
Article #1203

linebuffering & input

#1203
From: Richard A. O'Keefe
Date: Thu, 29 Sep 1988 02:04
30 lines
1309 bytes
This problem exists in SunOS 3.2 and DYNIX "V3.0.12 NFS", so I suspect
that it is a 4.2BSD problem.

% man 3 setbuf
tells us that "when <an output stream> is line buffered, characters are
saved up until a newline is encountered or input is read from stdin."
"setlinebuf is used to change the buffering on a stream from block
buffered or unbuffered to line buffered.  Unlike setbuf and setbuffer
it can be used at any time that the file descriptor is active".

However, the ONLY streams which are flushed when input is read from
stdin are stdout and stderr.

cat >linebug.c <<'END-OF-BUG'
#include <stdio.h>
main()
    {
        char buffer[80];
        FILE *terminal = fopen("/dev/tty", "w");
        
        setlinebuf(terminal);
        fprintf(terminal, "Prompt: ");
        gets(buffer);
	exit(0);
    }
END-OF-BUG
cc -o linebug linebug.c
./linebug

The prompt does not appear until after you have typed the input.
Technical Details
Message-ID: <486@quintus.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!seismo!sundc!pitstop!sun!quintus!ok

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!seismo!sundc!pitstop!sun!quintus!ok
From: ok@quintus (Richard A. O'Keefe)
Newsgroups: comp.bugs.4bsd
Subject: linebuffering & input
Message-ID: <486@quintus.UUCP>
Date: 29 Sep 88 02:04:32 GMT
Sender: news@quintus.UUCP
Reply-To: ok@quintus (Richard A. O'Keefe)
Organization: Quintus Computer Systems, Inc.
Lines: 30