xserver/os
Twaik Yont 032715f273 os: use close-on-exec for X server socket to prevent fd leaks
In most typical Linux X servers (like Xvfb, Xephyr, or Xwayland), no child process outlives the server, so this issue rarely arises. However, in embedded X servers (based on Xvfb or Kdrive) or in custom Xorg modules, the server might launch a long-running command with regular fork+exec calls. If the X server crashes or exits while that command is still running (for example, it spawns a tombstone generator or any process that hangs or turns to zombie), the file descriptor associated with the abstract socket can remain open in the child process. This leads to the kernel refusing to allow another X server to bind the same socket until the child process terminates (because there is no explicit way to unlink abstract socket, unlike Unix socket). By marking the file descriptor as close-on-exec, we ensure it is automatically closed in child processes, preserving the ability of a new X server process to bind the socket immediately.

Signed-off-by: Twaik Yont <9674930+twaik@users.noreply.github.com>
(cherry picked from commit 5568b0f83f)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2146>
2026-03-28 16:40:00 +00:00
..
.gitignore dix and os: gitignore dix.O and os.O 2011-09-23 17:14:47 -07:00
access.c os: Fix NULL pointer dereference 2025-02-05 15:02:23 +01:00
auth.c Switch to libbsd-overlay 2023-10-23 23:30:14 -04:00
backtrace.c os: include unistd.h when HAVE_PSTACK is defined 2021-05-27 21:33:12 +00:00
busfault.c os: Fix iteration over busfaults 2017-02-23 09:20:48 +10:00
client.c Return NULL in *cmdname if the client argv or argv[0] is NULL 2024-10-22 21:07:14 +00:00
connection.c os: use close-on-exec for X server socket to prevent fd leaks 2026-03-28 16:40:00 +00:00
inputthread.c os, shm: fcntl()'s third argument is integer, not pointer 2020-12-18 09:36:30 -05:00
io.c os: Check for integer overflow on BigRequest length 2025-06-18 17:54:47 +02:00
log.c os: avoid potential out-of-bounds access at logVHdrMessageVerb 2025-10-08 17:54:33 +02:00
Makefile.am dtrace: Move Xserver.d from dix/ to include/ 2019-08-27 17:38:54 -04:00
meson.build meson: Fix warnings when reading back and checking feature flags 2021-07-05 12:46:14 +00:00
mitauth.c os: make MitGenerateCookie() independent of XCSECURITY 2017-08-22 10:59:40 -04:00
oscolor.c Use ARRAY_SIZE all over the tree 2017-10-30 13:45:20 -04:00
osdep.h os: Remove mffs() 2017-11-06 17:22:46 -05:00
osinit.c os: Make OsSignalHandler ask for core dumps for signo != SIGQUIT 2017-12-13 11:11:42 -05:00
ospoll.c os: include <assert.h> in ospoll.c 2026-03-28 16:40:00 +00:00
ospoll.h os: Add ospoll interface [v2] 2016-07-21 15:04:47 -04:00
reallocarray.c Import reallocarray() from OpenBSD 2015-04-21 16:57:08 -07:00
rpcauth.c auth: remove AuthToIDFunc and associated functions. Not used anymore. 2017-02-28 14:15:19 -05:00
strcasecmp.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
strcasestr.c Remove unneeded include of dix.h from strcasestr.c 2019-04-30 20:07:51 +00:00
strlcat.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
strlcpy.c Introduce a consistent coding style 2012-03-21 13:54:42 -07:00
strndup.c os: Ensure <dix-config.h> is included in strndup.c 2013-02-14 09:20:46 -08:00
timingsafe_memcmp.c timingsafe_memcmp: Fix meson build 2017-05-10 10:56:16 -04:00
utils.c os: make FormatInt64() handle LONG_MIN correctly 2026-03-28 16:40:00 +00:00
WaitFor.c os: NextDPMSTimeout: mark intentional fallthroughs in switch 2025-02-05 15:02:23 +01:00
xdmauth.c auth: remove AuthToIDFunc and associated functions. Not used anymore. 2017-02-28 14:15:19 -05:00
xdmcp.c include: Remove now-empty site.h 2019-10-30 16:17:04 +00:00
xprintf.c os/xprintf: add Xvscnprintf and Xscnprintf 2012-05-03 14:59:23 +10:00
xserver_poll.c os: Fix build of xserver_poll.c on MinGW 2019-05-18 14:59:38 +00:00
xsha1.c os: Use EVP APIs when building with OpenSSL 3 2025-10-08 17:54:33 +02:00
xstrans.c Clean up a couple of warnings in os/ 2013-10-31 16:58:12 -07:00