Mail Archives: djgpp-workers/2001/08/05/14:46:17
> 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 -