From 3868f364728ae0cc35621bbfdd36bfa2e3f09fda Mon Sep 17 00:00:00 2001 From: Jeremy Huddleston Sequoia Date: Mon, 20 Jun 2022 20:05:46 -0700 Subject: [PATCH] xf86-input-inputtest: Fix build on systems without SOCK_NONBLOCK Signed-off-by: Jeremy Huddleston Sequoia (cherry picked from commit 707f23dab8787b4154011186206dc9964e2ebc11) --- hw/xfree86/drivers/inputtest/xf86-input-inputtest.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c b/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c index 70f8fe964..63a48522a 100644 --- a/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c +++ b/hw/xfree86/drivers/inputtest/xf86-input-inputtest.c @@ -1005,7 +1005,19 @@ pre_init(InputDriverPtr drv, InputInfoPtr pInfo, int flags) unlink(driver_data->socket_path); +#ifdef SOCK_NONBLOCK driver_data->socket_fd = socket(PF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0); +#else + int fd = socket(PF_UNIX, SOCK_STREAM, 0); + if (fd >= 0) { + flags = fcntl(fd, F_GETFL, 0); + if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) { + fd = -1; + } + } + driver_data->socket_fd = fd; +#endif + if (driver_data->socket_fd < 0) { xf86IDrvMsg(pInfo, X_ERROR, "Failed to create a socket for communication: %s\n", strerror(errno));