07/04/27 21:53:32 8003YhUG
ちょっと質問なんですがinotifyを利用しようとちょこちょこっとサンプルを書いてみたのですが、
動作仕様がどうにも理解に苦しみます。下のように、ループでreadしてブロッキングすると、最初の一回だけはreadするのですが、2回目以降無反応になってしまいます。
/* size of the event structure, not counting name */
#define EVENT_SIZE (sizeof (struct inotify_event))
/* reasonable guess as to size of 1024 events */
#define BUF_LEN (1024 * (EVENT_SIZE + 16)
char buf[BUF_LEN];
int len, i = 0;
int fd = inotify_init();
int wd = inotify_add_watch(fd, "/usr/local/hoge", IN_ACCESS | IN_MODIFY);
while(1){
len = read (fd, buf, BUF_LEN);
}