Signed-off-by: Hans de Goede <hdegoede@redhat.com>
if (ret != 0) {
return ret;
}
- ret = fcntl(pipefd[1], F_SETFD, O_NONBLOCK);
+ ret = fcntl(pipefd[1], F_GETFL);
+ if (ret == -1) {
+ usbi_dbg("Failed to get pipe fd flags: %d", errno);
+ goto err_close_pipe;
+ }
+ ret = fcntl(pipefd[1], F_SETFL, ret | O_NONBLOCK);
if (ret != 0) {
usbi_dbg("Failed to set non-blocking on new pipe: %d", errno);
- usbi_close(pipefd[0]);
- usbi_close(pipefd[1]);
+ goto err_close_pipe;
}
+
+ return 0;
+
+err_close_pipe:
+ usbi_close(pipefd[0]);
+ usbi_close(pipefd[1]);
return ret;
}
-#define LIBUSB_NANO 10739
+#define LIBUSB_NANO 10740