* /proc/kmsg blocks with O_NONBLOCK, read() should return 0 with EAGAIN
@ 2004-02-23 12:24 Graham Swallow
2004-02-24 0:01 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Graham Swallow @ 2004-02-23 12:24 UTC (permalink / raw)
To: linux-kernel
/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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: /proc/kmsg blocks with O_NONBLOCK, read() should return 0 with EAGAIN
2004-02-23 12:24 /proc/kmsg blocks with O_NONBLOCK, read() should return 0 with EAGAIN Graham Swallow
@ 2004-02-24 0:01 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2004-02-24 0:01 UTC (permalink / raw)
To: Graham Swallow; +Cc: linux-kernel
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);
}
_
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-02-24 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-23 12:24 /proc/kmsg blocks with O_NONBLOCK, read() should return 0 with EAGAIN Graham Swallow
2004-02-24 0:01 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).