delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/08/04/19:14:16

From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
Message-Id: <10108042310.AA13147@clio.rice.edu>
Subject: Re: Windows 2000 /dev/null permission query
To: djgpp-workers AT delorie DOT com
Date: Sat, 4 Aug 2001 18:10:33 -0500 (CDT)
Cc: acottrel AT ihug DOT com DOT au, eliz AT is DOT elta DOT co DOT il (Eli Zaretskii)
In-Reply-To: <10108041914.AA13523@clio.rice.edu> from "Charles Sandmann" at Aug 04, 2001 02:14:24 PM
X-Mailer: ELM [version 2.5 PL2]
Mime-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> > It's not a Bash issue, it's an issue with one of our library functions
> > called when we redirect output: some of them fail on Windows 2000 when
> > the target is the null device (or maybe any device they emulate for
> > DOS).
> 
> In particular, open on /dev/null fails using O_TRUNC

In this case we attempt a write to the device of 0 bytes.  This
write fails with dos error code of 5 = Access denied.

It appears to me the easiest fix for this is in open.c, which has a
section which looks like:

  if ((oflag & O_TRUNC) && !should_create)
    if (_write(fd, 0, 0) < 0)
      return -1;

would be to ignore the return code from _write in this case:

  if ((oflag & O_TRUNC) && !should_create)
    _write(fd, 0, 0);

Comments?  Can anyone think of a real case we would expect a write of 0
bytes to fail and we would want that to be fatal to the open?  The 
handle is open and allocated...

- Raw text -


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