Subject: Re: write() returning -1 and EINTR?
To: None <netbsd-users@netbsd.org>
From: David S. <davids@idiom.com>
List: netbsd-users
Date: 12/16/2002 23:41:17
> > 
> > Almost never!
> > Probably only for writes of less than PIPE_MAX bytes to pipes.
> > Maybe it depends on what you mean by 'atomic'.
> 
> As in, if I write() a meg of data to disk and I get a signal in the
> middle, does the write() complete before the signal is delivered?
> A friend of mine swears the write() completes first.

My "POSIX Programmer's Guide" reads:

   Synopsis:

	#include <unistd.h>
	int write(int fildes, const void *buf, unsigned int nbyte)
        ...

	If a 'write' is interrupted by a signal, it will either return
	-1 with 'errno' set to 'EINTR" or it will return a the non-zero
	number of bytes written.  A 'write' to a pipe will never return
	'EINTR' if it has transferred any data and 'nybyte' is less than
	'PIPE_BUF".
 	...

David S.

> --