Mail Archives: djgpp-workers/2001/08/05/13:53:16
> > > It appears to me the easiest fix for this is in open.c, ...
> > > 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...
>
> I'd prefer to understand this problem a bit more. For starters, does
> it affect NUL alone, or any other character device emulated by NTVDM?
> To find out, try redirecting to PRN, LPT1, AUX, and CON.
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?
With the current code, if the write of 0 bytes fails, shouldn't we at least
close the handle instead of just returning?
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.
- Raw text -