Update
Possible bug in Firefox - https://bugzilla.mozilla.org/show_bug.cgi?id=1288293
Old Post
I am writing a inotify file watcher.
My main thread first creates a pipe with pipe and then creates a polling thread, and sends this thread the read fd of the pipe.
int mypipe[2];
rez = pipe(mypipe)
if (pipe(pipefd) == -1) {
exit(EXIT_FAILURE);
}
int mypipe_fd = mypipe[0];
My polling thread then starts an infinite poll by watching the inotify inotify_fd and the pipe mypipe_fd with poll like 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; // this the read end of the pipe generated on the 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 as poll gives -1 and errno of 4 endlessly. Same situation with select with either of the fd's or both.
I did more tests. Even doing just read(mypipe_fd, .., ..) or read(inotify_fd, .., ..) continuously gives me EINTR as well. Mind boggling! Does anyone know what can be causing this? This behavior is seen on Ubuntu 14.01 and OpenSUSE 42.1 (the ones i tested on).