/proc/kmsg blocks with O_NONBLOCK, read() should return 0 with EAGAIN
/proc/kmsg blocks with O_NONBLOCK, read() should return 0 with EAGAIN
fd = open( "/proc/kmsg", O_RDONLY|O_NONBLOCK ); ... poll() -- says read it len = read(fd,buff,len); // first read is fine ... len = read(fd,buff,len); // second read blocks
I call read() a second time, because I'm feeling lucky, (this is library code, which also reads from sockets).
I expected it to return 0 with errno==EAGAIN.
Instead it waits: do_syslog(2,buf,count);
I'm not on this list, so please raise a ticket, linux-2.4.23,
thanks
--
Graham
Information-Cascade (at) ntlworld.com
Quoted 11 lines · Graham Swallow
/proc/kmsgblocks withO_NONBLOCK,read()should return 0 with EAGAINfd = open( "/proc/kmsg", O_RDONLY|O_NONBLOCK ); ... poll() -- says read it len = read(fd,buff,len); // first read is fine ... len = read(fd,buff,len); // second read blocks
Quoted 6 lines
I call
read()a second time, because I'm feeling lucky, (this is library code, which also reads from sockets).I expected it to return 0 with errno==EAGAIN.
Instead it waits:do_syslog(2,buf,count);
Does this work?
fs/proc/kmsg.c renamed from fs/proc/kmsg.c~kmsg-nonblock +2 -0
@@ -32,6 +32,8 @@ static int kmsg_release(struct inode * istatic ssize_t kmsg_read (struct file * file,char * buf,size_t count,loff_t *ppos) { +if ((file->f_flags &O_NONBLOCK ) && !do_syslog (9 ,0 ,0 )) +return -EAGAIN ;return do_syslog (2 ,buf,count); }
_