mirror of
https://github.com/NixOS/nix.git
synced 2025-12-19 23:41:07 +01:00
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
|
||
|---|---|---|
| .. | ||
| build-remote | ||
| external-api-docs | ||
| internal-api-docs | ||
| libcmd | ||
| libexpr | ||
| libexpr-c | ||
| libexpr-test-support | ||
| libexpr-tests | ||
| libfetchers | ||
| libfetchers-tests | ||
| libflake | ||
| libflake-c | ||
| libflake-tests | ||
| libmain | ||
| libmain-c | ||
| libstore | ||
| libstore-c | ||
| libstore-test-support | ||
| libstore-tests | ||
| libutil | ||
| libutil-c | ||
| libutil-test-support | ||
| libutil-tests | ||
| nix | ||
| nix-build | ||
| nix-channel | ||
| nix-collect-garbage | ||
| nix-copy-closure | ||
| nix-env | ||
| nix-instantiate | ||
| nix-store | ||
| perl | ||
| nix-functional-tests | ||
| nix-manual | ||