1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-19 23:41:07 +01:00
nix/src
Jörg Thalheim d2483b1add Fix macOS HUP detection using kqueue instead of poll
On macOS, poll() is fundamentally broken for HUP detection. It loses event
subscriptions when EVFILT_READ fires without matching the requested events
in the pollfd. This causes daemon processes to linger after client disconnect.

This commit replaces poll() with kqueue on macOS, which is what poll()
uses internally but without the bugs. The kqueue implementation uses
EVFILT_READ which works for both sockets and pipes, avoiding EVFILT_SOCK
which only works for sockets.

On Linux and other platforms, we continue using poll() with the standard
POSIX behavior where POLLHUP is always reported regardless of requested events.

Based on work from the Lix project (https://git.lix.systems/lix-project/lix)
commit 69ba3c92db3ecca468bcd5ff7849fa8e8e0fc6c0

Fixes: https://github.com/NixOS/nix/issues/13847
Related: https://git.lix.systems/lix-project/lix/issues/729
Apple bugs: rdar://37537852 (poll), FB17447257 (poll)

Co-authored-by: Jade Lovelace <jadel@mercury.com>
(cherry picked from commit 1286d5db78)
2025-09-06 07:21:42 +00:00
..
build-remote Apply clang-format universally. 2025-07-18 22:36:36 +03:00
external-api-docs Format .nix files 2025-01-24 17:04:02 +01:00
internal-api-docs Format .nix files 2025-01-24 17:04:02 +01:00
libcmd treewide: Apply clang-format 2025-08-18 21:20:40 +03:00
libexpr libexpr: Canonicalize TOML timestamps for toml11 > 4.0 2025-08-19 00:14:35 +03:00
libexpr-c Apply clang-format universally. 2025-07-18 22:36:36 +03:00
libexpr-test-support Apply clang-format universally. 2025-07-18 22:36:36 +03:00
libexpr-tests treewide: Apply clang-format 2025-08-18 21:20:40 +03:00
libfetchers treewide: Apply clang-format 2025-08-18 21:20:40 +03:00
libfetchers-tests Apply clang-format universally. 2025-07-18 22:36:36 +03:00
libflake Apply clang-format universally. 2025-07-18 22:36:36 +03:00
libflake-c Expose the nix component in header include paths 2025-04-02 11:37:17 -04:00
libflake-tests Apply clang-format universally. 2025-07-18 22:36:36 +03:00
libmain libmain: Catch logger exceptions in handleExceptions 2025-08-02 19:51:31 +00:00
libmain-c Expose the nix component in header include paths 2025-04-02 11:37:17 -04:00
libstore treewide: Apply clang-format 2025-08-18 21:20:40 +03:00
libstore-c Expose the nix component in header include paths 2025-04-02 11:37:17 -04:00
libstore-test-support treewide: Apply clang-format 2025-08-18 21:20:40 +03:00
libstore-tests treewide: Apply clang-format 2025-08-18 21:20:40 +03:00
libutil Fix macOS HUP detection using kqueue instead of poll 2025-09-06 07:21:42 +00:00
libutil-c Apply clang-format universally. 2025-07-18 22:36:36 +03:00
libutil-test-support Apply clang-format universally. 2025-07-18 22:36:36 +03:00
libutil-tests treewide: Apply clang-format 2025-08-18 21:20:40 +03:00
nix nix/develop: Fix misleading ignored error when run with --arg/--argstr 2025-08-29 21:18:40 +00:00
nix-build treewide: Apply clang-format 2025-08-18 21:20:40 +03:00
nix-channel Apply clang-format universally. 2025-07-18 22:36:36 +03:00
nix-collect-garbage Apply clang-format universally. 2025-07-18 22:36:36 +03:00
nix-copy-closure Expose the nix component in header include paths 2025-04-02 11:37:17 -04:00
nix-env treewide: Apply clang-format 2025-08-18 21:20:40 +03:00
nix-instantiate Apply clang-format universally. 2025-07-18 22:36:36 +03:00
nix-store Apply clang-format universally. 2025-07-18 22:36:36 +03:00
perl flake: Apply nixfmt 1.0.0 2025-08-18 21:17:24 +03:00
nix-functional-tests Build Functional tests with Meson 2024-08-14 15:35:40 -04:00
nix-manual Build the manual with Meson 2024-10-09 11:58:17 -04:00