diff options
Diffstat (limited to 'usr/src/lib/libc')
-rw-r--r-- | usr/src/lib/libc/port/sys/epoll.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/usr/src/lib/libc/port/sys/epoll.c b/usr/src/lib/libc/port/sys/epoll.c index 93379b583e..b8992e064b 100644 --- a/usr/src/lib/libc/port/sys/epoll.c +++ b/usr/src/lib/libc/port/sys/epoll.c @@ -10,7 +10,7 @@ */ /* - * Copyright (c) 2014, Joyent, Inc. All rights reserved. + * Copyright 2016 Joyent, Inc. */ #include <sys/types.h> @@ -114,7 +114,7 @@ epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) { dvpoll_epollfd_t epoll[2]; uint32_t events, ev = 0; - int i = 0; + int i = 0, res; epoll[i].dpep_pollfd.fd = fd; @@ -165,8 +165,20 @@ epoll_ctl(int epfd, int op, int fd, struct epoll_event *event) } epoll[i].dpep_pollfd.events = ev; - - return (write(epfd, epoll, sizeof (epoll[0]) * (i + 1)) == -1 ? -1 : 0); + res = write(epfd, epoll, sizeof (epoll[0]) * (i + 1)); + + if (res == -1) { + if (errno == ELOOP) { + /* + * Convert the specific /dev/poll error about an fd + * loop into what is expected from the Linux epoll + * interface. + */ + errno = EINVAL; + } + return (-1); + } + return (0); } int |