chiark / gitweb /
libudev: ctrl - log accept4() errors
[elogind.git] / libudev / libudev-ctrl.c
index 7fa2d1d..61e0243 100644 (file)
@@ -91,7 +91,7 @@ struct udev_ctrl *udev_ctrl_new_from_socket_fd(struct udev *udev, const char *so
                return NULL;
 
        if (fd < 0) {
-               uctrl->sock = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_CLOEXEC, 0);
+               uctrl->sock = socket(AF_LOCAL, SOCK_SEQPACKET|SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
                if (uctrl->sock < 0) {
                        err(udev, "error getting socket: %m\n");
                        udev_ctrl_unref(uctrl);
@@ -184,8 +184,10 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl)
        conn->refcount = 1;
        conn->uctrl = uctrl;
 
-       conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC);
+       conn->sock = accept4(uctrl->sock, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK);
        if (conn->sock < 0) {
+               if (errno != EINTR)
+                       err(uctrl->udev, "unable to receive ctrl connection: %m\n");
                free(conn);
                return NULL;
        }