On Mon, 27 Dec 2010 09:21:00 +0800 "kernel.majianpeng" <kernel.majianpeng@xxxxxxxxx> 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 -- To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html