Write calls which do partial writes

Len Lattanzi len at synthesis.Synthesis.COM
Thu May 4 05:00:27 AEST 1989


In article <10198 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
:In article <103 at matrix.UUCP> neeraj at matrix.UUCP (neeraj sangal) writes:
:>        n = write(fd, buf, len);
:>    1. Can n be less than len if fd is NOT set to non-blocking?
:
:Certainly; if only some but not all bytes were transferred,
:for example due to the system call being interrupted by a signal,
:then the best thing for write() to report is the number of bytes
:successfully transferred.  (I forget whether IEEE 1003.1 ended up
:permitting this or not; it was hotly debated.)  Robust stdio
:implementations have to loop on the write() call until all bytes
:are transferred or an error occurs.

Does anyone know for sure about IEEE 1003.1?
A (-1,EINTR) return from write is worthless if some bytes were written.
And you'll have to depend on your signal handler to not smash errno.
Do any of these OS/C library standards define useful schemes for handling
system call error returns in a multi-threaded process besides every
signal handler doing a save and restore of errno?

-Len
 Len Lattanzi (len at Synthesis.com) <{ames,pyramid,decwrl}!mips!synthesis!len>
 Synthesis Software Solutions, Inc. 		The RISC Software Company
I would have put a disclaimer here but I already posted the article.



More information about the Comp.unix.wizards mailing list