From 6adf4f51718c97f4f824aeb1410899a2b88fea13 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 2 Apr 2024 20:36:52 +0530 Subject: [PATCH] O_CLOEXEC for linux joystick open --- glfw/linux_joystick.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/glfw/linux_joystick.c b/glfw/linux_joystick.c index 09952c6d3..884ac8bb8 100644 --- a/glfw/linux_joystick.c +++ b/glfw/linux_joystick.c @@ -27,6 +27,8 @@ // It is fine to use C99 in this file because it will not be built with VS //======================================================================== +#define _POSIX_C_SOURCE 200809L + #include "internal.h" #include @@ -39,6 +41,7 @@ #include #include #include +#include #ifndef SYN_DROPPED // < v2.6.39 kernel headers // Workaround for CentOS-6, which is supported till 2020-11-30, but still on v2.6.32 @@ -135,7 +138,7 @@ static bool openJoystickDevice(const char* path) } _GLFWjoystickLinux linjs = {0}; - linjs.fd = open(path, O_RDONLY | O_NONBLOCK); + linjs.fd = open(path, O_RDONLY | O_NONBLOCK | O_CLOEXEC); if (linjs.fd == -1) return false;