🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #1393

Re: cat /dev/ttya > /dev/null &

#1393
From: David Steffens
Date: Fri, 01 Sep 1989 04:38
35 lines
2164 bytes
In article <815@brazos.Rice.edu>
number1!perl%step@uunet.uu.net (Robert Perlberg) writes:

> This is a very old problem found on many UNIX systems.
Possible, but I doubt it.

> By the time your application is finished writing and closes the port,
> there is still quite a bit of data in the queue which has not yet gone out.
> Whatever data is still in the queue when the port is closed is thrown away.

Any UNIX on which this really is true is just plain _broken_.  The tty
driver is responsible for getting the chars out even _after_ the process
has gone away.

> This results in the "missing pages" problem reported by many lpr users.
Actually, I believe the problem is caused by _re-opening_ the tty line
before all of the output from the previous write has drained.

I've seen a similar problem on a hard-copy console at boot time -- the
messages from /etc/rc are truncated.  The tty driver is apparently
flushing all pending output when the _first_ open occurs on a line.  In
both the case of lpr and /etc/rc messages, no other process has the line
open for write, so every open is the first one.  Ergo, it is the "write...
last close... first open" cycle which tickles the bug.

> The solution is to make sure that the tty port is not
> closed until after all of the data has been transmitted.

You are correct... at least until Sun fixes the _real_ bug.  However, a
better way of describing the required work-around is: make sure there is
_at least one_ writer active on the line at all times.

{harvard,mit-eddie,think}!eplunix!das	David Allan Steffens
243 Charles St., Boston, MA 02114	Eaton-Peabody Laboratory
(617) 573-3748				Mass. Eye & Ear Infirmary
Technical Details
Message-ID: <1426@brazos.Rice.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!rice!sun-spots-request
From: harvard!eplunix!das@a.cs.uiuc.edu (David Steffens)
Newsgroups: comp.sys.sun
Subject: Re: cat /dev/ttya > /dev/null &
Keywords: Miscellaneous
Message-ID: <1426@brazos.Rice.edu>
Date: 1 Sep 89 04:38:26 GMT
Sender: root@rice.edu
Organization: Sun-Spots
Lines: 35
Approved: Sun-Spots@rice.edu
X-Sun-Spots-Digest: Volume 8, Issue 119, message 6 of 15