| diff -Naur a/udev/udev-ctrl.c b/udev/udev-ctrl.c |
| --- a/udev/udev-ctrl.c 2011-10-09 16:10:32.974583654 -0700 |
| +++ b/udev/udev-ctrl.c 2016-10-24 13:41:53.973027666 -0700 |
| @@ -15,6 +15,7 @@ |
| #include <stddef.h> |
| #include <string.h> |
| #include <unistd.h> |
| +#include <fcntl.h> |
| #include <sys/types.h> |
| #include <sys/poll.h> |
| #include <sys/socket.h> |
| @@ -176,6 +177,16 @@ |
| return uctrl->sock; |
| } |
| |
| +int replace_accept4(int s, struct sockaddr *addr, socklen_t *addrlen, int flags) |
| +{ |
| + int sock = accept(s, addr, addrlen); |
| + if (sock < 0) return sock; |
| + int res = fcntl(sock, F_SETFL, flags); |
| + if (res > -1) return sock; |
| + close(sock); |
| + return res; |
| +} |
| + |
| struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) |
| { |
| struct udev_ctrl_connection *conn; |
| @@ -189,7 +200,8 @@ |
| conn->refcount = 1; |
| conn->uctrl = uctrl; |
| |
| - conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK); |
| + //conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK); |
| + conn->sock = replace_accept4(uctrl->sock, NULL, NULL, O_NONBLOCK); |
| if (conn->sock < 0) { |
| if (errno != EINTR) |
| err(uctrl->udev, "unable to receive ctrl connection: %m\n"); |