Subject: Re: Possible bug relating to malloc()/realloc(), popen(), and read()
To: None <port-i386@NetBSD.org>
From: Vincent Stemen <netbsd@crel.us>
List: port-i386
Date: 12/02/2004 17:37:04
On Thu, Dec 02, 2004 at 03:55:37PM -0600, James Chacon wrote:
> On Thu, Dec 02, 2004 at 12:58:41PM -0600, Vincent Stemen wrote:
> > On Thu, Dec 02, 2004 at 03:25:35PM +0100, Martin Husemann wrote:
> > > Your program does not properly handle return values from read(). You need
> > > to check -1 and errno == EAGAIN at least, if you don't read from straight
> > > disk files.
> > > 
> > > Martin
> > 
> > It does check for -1.  According to the manual, EAGAIN is only for
> > non-blocking I/O which I did not think applied in this case.
> 
> Actually I beleive you can get it on an interruption as well (say attaching
> with the debugger). I don't recall if read does an automatic restart when
> getting a signal or just returns EAGAIN.
> 
> James

I dug a bit further and, so far as I can tell according to the
manuals, read(), along with several other I/O system calls, terminates
with errno set to EINTR if interrupted before it is committed unless
the SA_RESTART sigaction flag is set to request the restarting of
pending calls.

-- 
Vincent Stemen
Avoid the VeriSign/Network Solutions domain registration trap!
Read how Network Solutions (NSI) was involved in stealing our domain name.
http://www.InetAddresses.net