OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
A question about read(2) in ntpd/bgpd

From: Valentin Kozamernik (tinkomna.com)
Date: Sun Mar 18 2007 - 10:13:50 CDT


While reading through ntpd and bgpd sources I came across a piece of
code I don't fully understand.

The imsg_read() function uses read(2) and returns 0 on EOF, EINTR or
EAGAIN. But whereever imsg_read() is used it is assumed that the
return value of 0 means that the socket has been closed.

I understand that since imsg_read() is only used after a POLLIN
indication from poll(2) and there are no other processes reading from
the same fd, read(2) shouldn't result in EAGAIN.

But is there a reason why read(2) couldn't be interrupted by a signal
and return EINTR? Or does this only happen with a blocking read(2)?
The man page isn't clear about this.

--
Tin