> -----Original Message----- > From: Liu Yuan [mailto:namei.unix at gmail.com] > Sent: Wednesday, April 25, 2012 10:15 AM > To: Huxinwei > Cc: MORITA Kazutaka; sheepdog at lists.wpkg.org > Subject: Re: [Sheepdog] [PATCH] fix a bug in rx() when read() returns 0 but > connection is not marked as closed. > > On 04/25/2012 09:05 AM, Huxinwei wrote: > > > What if reading is interrupted by a signal ? > > Read() returns 0 while errno is EINTR then ? > > > is there any real use case to interrupt read()? If it is killed by > manual signal, I think it would be too artificial Er, I was wrong. The Linux kernel guarantees that if read is interrupted before reading any data, the return value is -1. So 0 always means EOF unless the count is 0 too. It is sufficient to check returning value to determinate the status of the connection. ;) Thanks. > Thanks, > Yuan |