lkml.org 
[lkml]   [2004]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: /proc/kmsg blocks with O_NONBLOCK, read() should return 0 with EAGAIN
Graham Swallow <Information-Cascade@ntlworld.com> wrote:
>
> /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);
>

Does this work?


diff -puN fs/proc/kmsg.c~kmsg-nonblock fs/proc/kmsg.c
--- 24/fs/proc/kmsg.c~kmsg-nonblock Mon Feb 23 16:00:48 2004
+++ 24-akpm/fs/proc/kmsg.c Mon Feb 23 16:01:12 2004
@@ -32,6 +32,8 @@ static int kmsg_release(struct inode * i
static 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);
}

_

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:01    [W:0.400 / U:0.568 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site