www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/04/08/05:19:15

Date: Thu, 8 Apr 1999 11:17:08 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Michel de Ruiter <Michel AT smr DOT nl>
cc: "'DJGPP workers'" <djgpp-workers AT delorie DOT com>
Subject: RE: setmode problem
In-Reply-To: <B0FEA00E82A7D1118BFB00A0CC99027821323A@ARGON>
Message-ID: <Pine.SUN.3.91.990408111636.29868K-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 6 Apr 1999, Michel de Ruiter wrote:

> > > All problems disappeared when I set stdin to _IONBF (not buffered)
> > > instead of _IOLBF (line buffered). At least, just one key press is
> > > enough to let the C-BREAK through.
> > I'm worried about the possible implications of turning off 
> > the buffering just because somebody reads in binary mode.
> > Can anybody think of any downside to this change?  If not,
> > let's do it.
> 
> Or let's just fix "all" the applications using setmode(O_BINARY)...

Most of them are fixed already, actually (I had something to do with
that ;-).

I thought about this problem a bit more, and don't think the simple
solution you propose is enough.  Imagine a program that switches stdin
to binary mode and also redirects it to a file with `dup'.  With your
change, the result will depend on the order of these two operations:
in one case, you wind up with an unbuffered file, in the other it is
buffered.

So at least some changes in other functions, like `dup' and `dup2'
will be necessary to prevent these subtle ``features''.

> And it's documentation in setmode.txh.

I thought setmode.txh already tells enough about this issue.  If not,
please tell what's missing.

> It seems this problem is already known among some DJGPP "porters" but not
> all. We (someone how knows most about this) should document this somewhere
> at least...

I agree, and I put this information in setmode.txh, open.txh,
fopen.txh, and signal.txh exactly for that reason.  Again, if
something's missing from that description, please tell what it is.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019