What's a good prototype for write(2)?

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Oct 30 07:45:01 AEST 1988


In article <2991 at ttrdc.UUCP> levy at ttrdc.UUCP (Daniel R. Levy) writes:
-not taking into account the possibility of a "short write" which is yet
-not the result of an error condition.  I was burned like this when porting
-a game program which originally ran on System V, which to do a save writes
-off its entire data segment in one big write(), to the Eunice emulation of
-BSD under VMS.  write() would only work in 65k chunks, as I recall, and
-I had to use a loop.

Yes, you should always loop on successful writes until all the data is
transferred, unless it is known that exact record size is important (as
on a magtape duplicator).

I think I'll post my 9th Ed. UNIX-compatible "cat" source as an example.



More information about the Comp.std.c mailing list