linux - poll(2) on read fd of pipe(2) and fd of inotify_init() is resulting in endless EINTR -
update
possible bug in firefox - https://bugzilla.mozilla.org/show_bug.cgi?id=1288293
old post
i writing inotify file watcher.
my main thread first creates pipe pipe
, creates polling thread, , sends thread read fd
of pipe.
int mypipe[2]; rez = pipe(mypipe) if (pipe(pipefd) == -1) { exit(exit_failure); } int mypipe_fd = mypipe[0];
my polling thread starts infinite poll watching inotify inotify_fd
, pipe mypipe_fd
poll
this:
int inotify_fd = inotify_init1(0); if (inotify_fd == -1) { exit('inotify init failed'); } // in_all_events = in_access | in_modify | in_attrib | const.in_close_write | in_close_nowrite | in_open | in_moved_from | in_moved_to | in_create | in_delete | in_delete_self | in_move_self if (inotify_add_watch(inotify_fd, path_to_desktop, in_all_events) == -1) { exit('add watch failed'); } int mypipe_fd = blah; // read end of pipe generated on main thread pollfd fds[2]; fds[0].fd = mypipe_fd; fds[1].fd = inotify_fd; fds[0].events = pollin; fds[1].events = pollin; if (poll(fds, 2, -1) == -1) { exit(errno); }
this exits poll
gives -1
, errno
of 4
endlessly. same situation select
either of fd
's or both.
i did more tests. doing read(mypipe_fd, .., ..)
or read(inotify_fd, .., ..)
continuously gives me eintr
well. mind boggling! know can causing this? behavior seen on ubuntu 14.01 , opensuse 42.1 (the ones tested on).
Comments
Post a Comment