fix(libkernel): create pipes with pipe and fcntl on macOS, where pipe2 needs macOS 27 #19903
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19903"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by XIIYAZ on 2026-11-14T07:27:58Z.
What
pipe2_nid_postfixcalls the host::pipe2on every non-Windows host. In the macOS 27 SDK,sys/unistd.hdeclarespipe2(anddup3) with__API_AVAILABLE(macos(27.0), ...), and the libraries are built with a lower minimum version (LC_BUILD_VERSION minos 26.0here), sopipe2is weakly imported. On macOS 26 it resolves to null, and the first guestpipeorpipe2jumps to address 0:The compiler reports it as
'pipe2' is only available on macOS 27.0 or neweratStdio.cpp:767. With an SDK older than 27,pipe2is not declared and the file does not compile.On macOS the pipe is now made with
pipe, thenFD_CLOEXECandO_NONBLOCKare set withfcntlwhen requested; if eitherfcntlfails, both descriptors are closed and the call fails with thaterrno. This works on every macOS version and SDK. Unlikepipe2, close-on-exec is not set atomically with the creation, so a concurrentfork/execin another thread can inherit the descriptors in that window. Linux and Windows are unchanged.Tested
macOS 26.7.3, Apple M4, Xcode SDK 27.2, Apple clang 21.0.0, CMake 4.4.4, Ninja, full build (
-DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_OSX_ARCHITECTURES=x86_64, tests run under Rosetta) onmainwith #17425, #11049 and #11437 merged locally for the other macOS build breaks.guest_dup,guest_file_timestamps,guest_filesystem,guest_fstatfs,guest_fstatvfs,guest_getrlimit,guest_host_standard_error,guest_host_streams,guest_kernel_fcntl,guest_kernel_fcntl_sync,guest_kernel_fstat,guest_kernel_ioctl_fionread,guest_kernel_pipe2,guest_kernel_sock_names,guest_kernel_socket_shutdown,guest_kernel_sys_aio,guest_kernel_sys_dup,guest_kernel_sys_pselect,guest_kernel_sys_pwrite,guest_kernel_sys_pwrite_patched,guest_kernel_web_forwards,guest_kqueue,guest_pipe_fault,guest_poll,guest_posix_filesystem,guest_posix_scalar_io,guest_select,guest_socket_descriptor_flags,guest_socket_events,guest_socket_on_non_socket,guest_socket_rights,guest_terminal.'pipe2' is only available on macOS 27.0 or newerwarning forStdio.cppis gone.python3 tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)