Mail Archives: djgpp/1997/09/14/14:57:16
On Fri, 12 Sep 1997, Vik Heyndrickx wrote:
> When _write is called with a count of 0, the file gets truncated. Is
> this POSIX behaviour?
`_write' is not a POSIX function, so this has nothing to do with what
POSIX rules. The corresponding POSIX function is `write', and its
DJGPP version does in fact return without doing anything when count is
zero.
The DOS function which `_write' calls is documented to truncate the
file when a zero count is passed to it. For example, here's the
relevant fragment from ralf Brown's Interrupt List:
--------D-2140-------------------------------
INT 21 - DOS 2+ - "WRITE" - WRITE TO FILE OR DEVICE
AH = 40h
BX = file handle
CX = number of bytes to write
DS:DX -> data to write
Return: CF clear if successful
AX = number of bytes actually written
CF set on error
AX = error code (05h,06h) (see #1332 at AH=59h/BX=0000h)
Notes: if CX is zero, no data is written, and the file is truncated or
extended to the current position
- Raw text -