#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <stdbool.h>
#include <common/error.h>
#include <common/defaults.h>
/*
* Wait on epoll set. This is a blocking call of timeout value.
*/
-int compat_epoll_wait(struct lttng_poll_event *events, int timeout)
+int compat_epoll_wait(struct lttng_poll_event *events, int timeout,
+ bool interruptible)
{
int ret;
uint32_t new_size;
do {
ret = epoll_wait(events->epfd, events->events, events->nb_fd, timeout);
- } while (ret == -1 && errno == EINTR);
+ } while (!interruptible && ret == -1 && errno == EINTR);
if (ret < 0) {
- /* At this point, every error is fatal */
- PERROR("epoll_wait");
+ if (errno != EINTR) {
+ PERROR("epoll_wait");
+ }
goto error;
}
fd = open(COMPAT_EPOLL_PROC_PATH, O_RDONLY);
if (fd < 0) {
- retval = -1;
+ /*
+ * Failing on opening [1] is not an error per see. [1] was
+ * introduced in Linux 2.6.28 but epoll is available since
+ * 2.5.44. Hence, goto end and set a default value without
+ * setting an error return value.
+ *
+ * [1] /proc/sys/fs/epoll/max_user_watches
+ */
+ retval = 0;
goto end;
}