delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/08/05/14:46:17

Date: Sun, 05 Aug 2001 21:43:50 +0300
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: sandmann AT clio DOT rice DOT edu
Message-Id: <8011-Sun05Aug2001214350+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
CC: acottrel AT ihug DOT com DOT au, djgpp-workers AT delorie DOT com
In-reply-to: <10108051749.AA17568@clio.rice.edu> (sandmann@clio.rice.edu)
Subject: Re: Windows 2000 /dev/null permission query
References: <10108051749 DOT AA17568 AT clio DOT rice DOT edu>
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

> From: sandmann AT clio DOT rice DOT edu (Charles Sandmann)
> Date: Sun, 5 Aug 2001 12:49:25 -0500 (CDT)
> 
> It also fails for "con" which was easy to test.  
> It did not fail for "prn", "aux", or "com1"
> 
> > If this only affects character devices, we can test the handle for
> > being connected to a character device, and _then_ ignore the error.  I
> > don't think we should ignore it for disk files: that would be a subtle
> > misfeature.
> 
> If a write of 0 bytes to a disk file fails (why/how would this ever
> happen?), then the first write the user performs should also fail?

If you'd ask me a few days ago, I'd probably say YES.  But now, after
reading about the crazy things W2K does, I no longer dare to guess
what might Redmond boys and gals give us next ;-)

I'd say, let's test for a character device (it's a single Int 21h
call), and then ignore the error.  FWIW, I know that some (but not
all) versions of Windows 9X also don't like "foo > prn", but allow
"foo >>prn".  Truncating a device doesn't make sense anyway, so we
probably should avoid the _write call for devices altogether.

> With the current code, if the write of 0 bytes fails, shouldn't we at least 
> close the handle instead of just returning?

If we are going to fail _open, we should indeed close the handle,
otherwise we leak handles.

> I think this is a case where removing the check fixes the problem without
> having to make the code bigger, slower and more complex (and prone to future 
> issues) without any known downside.

I think it's generally wrong to ignore errors, especially for the sake
of a relatively marginal case (only one OS, and only for redirection
to the null device).

- Raw text -


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