From: Andrew Morton <akpm@osdl.org>
To: Graham Swallow <Information-Cascade@ntlworld.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: /proc/kmsg blocks with O_NONBLOCK, read() should return 0 with EAGAIN
Date: Mon, 23 Feb 2004 16:01:48 -0800 [thread overview]
Message-ID: <20040223160148.400895f3.akpm@osdl.org> (raw)
In-Reply-To: <20040223122410.6eb44df1.Information-Cascade@ntlworld.com>
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);
}
_
prev parent reply other threads:[~2004-02-24 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-23 12:24 Graham Swallow
2004-02-24 0:01 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040223160148.400895f3.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=Information-Cascade@ntlworld.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®