From: Neil Brown <neilb@suse.de>
To: "kernel.majianpeng" <kernel.majianpeng@gmail.com>
Cc: linux-raid <linux-raid@vger.kernel.org>
Subject: Re: using poll on /proc/mdstat
Date: Mon, 27 Dec 2010 17:27:19 +1100 [thread overview]
Message-ID: <20101227172719.01bae9db@notabene.brown> (raw)
In-Reply-To: <201012270920567187973@gmail.com>
On Mon, 27 Dec 2010 09:21:00 +0800 "kernel.majianpeng"
<kernel.majianpeng@gmail.com> wrote:
> Hi all:
> read Neil Brown's mail, I modified the function:
> char buff[4096] = {0};
> int fd = open("/proc/mdstat",O_RDONLY);
> if(fd < 0){
> printf("open /proc/mdstat error:%s\n",strerror(errno));
> return -errno;
> }
>
> struct pollfd fds[1];
> int ret;
>
> fds[0].fd = fd;
> fds[0].events = POLLPRI;
> while(1){
> fds[0].fd = fd;
> fds[0].events = POLLPRI;
> ret = poll(fds,1,-1);
> if(ret < 0){
> printf("poll error:%s\n",strerror(errno));
> break;
> }else
> printf("ret value=%d\n",fds[0].revents);
> read(fd,buff,4096);
> memset(buff ,0,4096);
> }
> close(fd);
>
> I add read command and confirm read end of file /proc/mdstat.
> But this fution also to find only one event.
You missed this bit:
> poll will only block again after you read to the end of the file (and thus
> observe any change), and then seek back to the start.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
NeilBrown
prev parent reply other threads:[~2010-12-27 6:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <201012251036232181820@gmail.com>
2010-12-25 2:49 ` (unknown), kernel.majianpeng
2010-12-26 11:44 ` using poll on /proc/mdstat Neil Brown
2010-12-27 1:21 ` kernel.majianpeng
2010-12-27 6:27 ` Neil Brown [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=20101227172719.01bae9db@notabene.brown \
--to=neilb@suse.de \
--cc=kernel.majianpeng@gmail.com \
--cc=linux-raid@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;
as well as URLs for NNTP newsgroup(s).