delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/08/19/12:19:29

Message-Id: <m0z98iZ-000XesC@sloep06.cs.vu.nl>
Date: Wed, 19 Aug 98 15:56:03 MET DST
From: Michel de Ruiter <mdruiter AT cs DOT vu DOT nl>
To: djgpp-workers AT delorie DOT com
Subject: stat c:/con

Workers,

I have encountered a problem with the current implementation of
`stat'. I think it is a result from a bug in DOS, but I am not sure.

I run MS-DOS 7.0 without Win95. The problem is inconsistent behaviour
of statting `c:/con'. I used the following small program:

#include <sys/stat.h>
int main(void) {
  struct stat s;
  return stat("c:/con", &s);
}

When I first run this program, the computer waits for me to input a
line (which is *not* OK, IMHO). If I type some text and press enter,
`stat' returns zero, and I am back at the command line, as expected.
But then, if I run the program again, there is no wait for input. If I
run it again and again, no input is required for the number of *bytes*
I typed the first time. So, it seems the text is in some DOS-buffer
which is read from at every `stat'.

Also, after the first `stat'ting and typing some text, if I run `cat',
an empty line is printed, followed by the last part of the typed text.
If I then end `cat' by typing ^Z, the "buffer" is empty (statting
requires input) again.

I think a discussion about this behaviour in Bash' redirection has
been up here some time ago. I know the latest Bash-1.14.7 (release 9
or so, from Daisuke's homepage) is corrected for this. But, shouldn't
this behaviour be corrected/worked around in libc (stat?) instead, if
possible?

I'm no expert at the internals of MS-DOS. I just saw this strange
behaviour and thought I should report it.

--
Groeten, Michel.        http://www.cs.vu.nl/~mdruiter
  ____________
  \  /====\  /          "You know, Beavis, you need things that suck,
   \/      \/           to have things that are cool", Butt-Head.

- Raw text -


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