delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1997/09/04/13:46:36

Date: Thu, 4 Sep 1997 20:42:34 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Oberhumer Markus <k3040e4 AT c210 DOT edvz DOT uni-linz DOT ac DOT at>
cc: djgpp-workers <djgpp-workers AT delorie DOT com>
Subject: Re: stdin + binmode (yet another one ;-)
In-Reply-To: <199709032209.SAA03594@delorie.com>
Message-ID: <Pine.SUN.3.91.970904204152.27525L-100000@is>
MIME-Version: 1.0

On Thu, 4 Sep 1997, Oberhumer Markus wrote:

I'm not saying I oppose your suggestion too strongly, but let me just
be the Devil's advocate here, so this issue doesn't look too one-sided,
OK?

> - Borland's, Microsoft's and Watcom's setmode don't do it (just checked),
>   so it's an incompatibility anyway

These are hardly a model for imitation.  At least Borland doesn't even
switch the device to raw mode, so you can't have true binary reads
from the console (e.g., read a single character with a call to `read'
library functions, or anything else that calls a DOS function).

> - Disabling Ctrl-C ought to be done via the termios stuff,
>   so it's a bad design

Don't forget that termios is with us only beginning with last 2.01
beta releases, and it is incomplete, whereas the Ctrl-C disable was
there in v2 from day one.  You will need to convert all programs that
want to see Ctrl-C to termios before you could remove that.

OTOH, nothing prevents you from using termios right now instead of
setmode, if you don't want the (mis)feature of the latter.  Whoever
uses the setmode method should read the docs carefully and understand
what they are doing.

> - Having to reboot your computer is EVIL ;-)

Don't set stdin to binary unless you know the perils ;-).

But seriously, setting a device to binary mode means you want true
binary reads, i.e. each character needs to get into the buffer
verbatim.  It is incorrect IMHO to have stdin in binary mode with a
caveat that Ctrl-C character cannot be read; it is much worse if
Ctrl-C will abort the program that is reading its input!

- Raw text -


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