Subject: Re: write() returning -1 and EINTR?
To: <>
From: David Laight <>
List: netbsd-users
Date: 12/16/2002 15:53:56
On Sun, Dec 15, 2002 at 06:32:30PM -0500, wrote:
> How can write() return a -1 with errno set to EINTR? Shouldn't write()
> return a 0 if it is interrupted and hasn't written anything out?

Nope, I'm fairly sure it should return EINTR and -1.
What is much more important, is that it must not return -1
and EINTR if it has transferred some data.
(This all came up at an X/Open meeting I was at wrt sockets.)

The other question is whether the system call should be restarted?
This probably depends on the signal.

> Then again, when exactly are writes atomic? Only when writing to disk?

Almost never!
Probably only for writes of less than PIPE_MAX bytes to pipes.
Maybe it depends on what you mean by 'atomic'.


David Laight: