feat(libc): support daemon on POSIX hosts #10453
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10453"
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 MarcZX10 on 2026-10-24T01:14:52Z.
What
Forward
daemonto the host implementation on POSIX systems. Preserve the explicit unsupported error on Windows, where the running guest process cannot be detached using POSIXforksemantics. Add subprocess coverage for allnochdir/noclosecombinations, checking session detachment, working directory, and standard descriptors. The behavior follows the fork/session/directory/descriptor contract shown in FreeBSD libc and OpenBSD libc; console behavior is not verified.Tested
Process.cppandGuestDaemon.cpp, linked the actual objects with section garbage collection, and ranGuestDaemonthree times. All four flag combinations passed.python3 tools/check_conventions.py --base upstream/main --head HEADpassed.git diff --checkpassed.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)Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T05:01:36Z.
Review: COMMENTED
Checked against main
6c52b649e7and FreeBSD 11.4 lib/libc/gen/daemon.c:::daemonmakes the emulator's own process_exit(0)(FreeBSD daemon.c does the same in the parent), and the guest continues in a child that has only the calling thread. The other guest threads and the render, audio and input threads don't exist there, and any lock they held stays locked. The emulator's shutdown callbacks never run, and withnoclose == 0its logs go to/dev/null. The new test forks a single-threaded helper first, so it can't show this. Could the debt entry describe it, or better, coulddaemonkeep throwing likefork(libkernel_sys/Export.cpp:322)?chdir("/")happens on the host, but the guest working directory is emulated (General.cpp:268-276,getcwd_nid_postfixat :788). Afterdaemon(0, 1), a guestgetcwd()still returns the previous directory, where FreeBSD returns "/".GuestErrnoFromHost_nid_no_patch. For example, a LinuxforkEAGAIN (11) reads as EDEADLK in FreeBSD numbering (FreeBSD's EAGAIN is 35).setsidfail with EPERM andforkthrow, and the PPSA85300 port cited in debt/libkernel.md stubsfork/vforkwith ENOSYS, which suggests a consoledaemon()fails rather than detaches. With no title calling it (the debt notes VLC needs--daemon), keeping the throw seems closer to the project rules than a host success.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Pull request closed