fix(libkernel): handle FIOCLEX and FIONCLEX in ioctl #5186

Merged
p3n1cillin merged 1 commit from upstream-pr/5186 into main 2026-10-14 03:31:09 +00:00
p3n1cillin commented 2026-10-13 14:09:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T14:09:59Z.


What

Carries @milescoviello's fix(libkernel): handle FIOCLEX and FIONCLEX in ioctl from #4505 (935213047, author kept). @oneandonlydean closed #4505 because no title had been shown to send these requests, and asked for it to come back "with the title ID and that line". Here they are.

PS5MC (PPSA99420, Kodi 22, catalog release), once #5183, #5184 and #5185 let it load and start Python:

terminate called after throwing an instance of 'std::runtime_error'
  what():  ioctl: request 0x20006601 on a file is not implemented, fd=3

0x20006601 is FIOCLEX. CPython marks the descriptors it opens non-inheritable through ioctl(fd, FIOCLEX) where that request exists, as on FreeBSD. The commit handles FIOCLEX and FIONCLEX on file descriptors the way FreeBSD's kern_ioctl does: it sets or clears the descriptor's close-on-exec flag, the same state fcntl(F_SETFD) already keeps. It forwards them for sockets as before. The debt entry for ioctl is updated (rebased onto the per-library debt files; the change is the same sentence as in #4505).

Tested

  • PS5MC PPSA99420 on Windows 11 (MinGW GCC 15.2.0), on main 3faa9cb40 with #4379, #4374, #4383, #5183, #5184 and #5185, without the host's HOME. Before, it aborts as above. After, Kodi finds its add-ons (kodi.binary.global.gui, skin.estuary, xbmc.python and others), logs CApplication::CreateGUI - using the ps5 windowing system, and runs for the whole 90 s run.
  • guest_kernel_fcntl (from the commit) and all 125 libkernel tests pass on Windows. Earlier reviews of #4505 covered Linux and Windows builds of the same change.
  • python tools/check_conventions.py --base origin/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none to build; PS5MC reaches it with #4379, #4374, #4383, #5183, #5184 and #5185
  • Unblocks: PS5MC (PPSA99420)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4844516210 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5186). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T14:09:59Z. --- ### What Carries @milescoviello's `fix(libkernel): handle FIOCLEX and FIONCLEX in ioctl` from #4505 (`935213047`, author kept). @oneandonlydean closed #4505 because no title had been shown to send these requests, and asked for it to come back "with the title ID and that line". Here they are. PS5MC (PPSA99420, Kodi 22, catalog release), once #5183, #5184 and #5185 let it load and start Python: ``` terminate called after throwing an instance of 'std::runtime_error' what(): ioctl: request 0x20006601 on a file is not implemented, fd=3 ``` `0x20006601` is `FIOCLEX`. CPython marks the descriptors it opens non-inheritable through `ioctl(fd, FIOCLEX)` where that request exists, as on FreeBSD. The commit handles `FIOCLEX` and `FIONCLEX` on file descriptors the way FreeBSD's `kern_ioctl` does: it sets or clears the descriptor's close-on-exec flag, the same state `fcntl(F_SETFD)` already keeps. It forwards them for sockets as before. The debt entry for `ioctl` is updated (rebased onto the per-library debt files; the change is the same sentence as in #4505). ### Tested - PS5MC PPSA99420 on Windows 11 (MinGW GCC 15.2.0), on `main` `3faa9cb40` with #4379, #4374, #4383, #5183, #5184 and #5185, without the host's `HOME`. Before, it aborts as above. After, Kodi finds its add-ons (`kodi.binary.global.gui`, `skin.estuary`, `xbmc.python` and others), logs `CApplication::CreateGUI - using the ps5 windowing system`, and runs for the whole 90 s run. - `guest_kernel_fcntl` (from the commit) and all 125 libkernel tests pass on Windows. Earlier reviews of #4505 covered Linux and Windows builds of the same change. - `python tools/check_conventions.py --base origin/main` passes. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none to build; PS5MC reaches it with #4379, #4374, #4383, #5183, #5184 and #5185 - [x] Unblocks: PS5MC (PPSA99420) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-13 14:19:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T14:19:59Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#5020 docs/dev/debt/libkernel.md L167-168
#5053 docs/dev/debt/libkernel.md L168
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147685701 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5186#issuecomment-6147685701). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T14:19:59Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #5020 | `docs/dev/debt/libkernel.md` [L167-168](https://github.com/boykopovar/AnyPS5/blob/a5f493f90dca348a65561aed4bb325a629d1b668/docs/dev/debt/libkernel.md#L167-L168) | | | | #5053 | `docs/dev/debt/libkernel.md` [L168](https://github.com/boykopovar/AnyPS5/blob/a5f493f90dca348a65561aed4bb325a629d1b668/docs/dev/debt/libkernel.md#L168) | | |
p3n1cillin commented 2026-10-13 14:34:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T14:34:49Z.


Linux run: Ubuntu in WSL2, GCC 15.2.0, Ninja Release, BUILD_TESTING=ON, full build of a local test head 838d4fd85. That head is main 3faa9cb40 with this PR, my other open libkernel PRs (#5013, #5061, #5078, #5098, #5183–#5187, #5191) and the open PRs the catalog titles need (#4377, #4379, #4374, #4383, #3798, #4467, #4863, #4105). All 123 libkernel and 69 libc tests pass, including guest_system_configuration, guest_getrlimit, guest_kernel_fcntl, guest_freebsd_clocks, guest_kernel_sys and guest_filesystem. Not built alone on Linux; no title run on Linux.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147992057 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5186#issuecomment-6147992057). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-13T14:34:49Z. --- Linux run: Ubuntu in WSL2, GCC 15.2.0, Ninja Release, `BUILD_TESTING=ON`, full build of a local test head `838d4fd85`. That head is `main` `3faa9cb40` with this PR, my other open libkernel PRs (#5013, #5061, #5078, #5098, #5183–#5187, #5191) and the open PRs the catalog titles need (#4377, #4379, #4374, #4383, #3798, #4467, #4863, #4105). All 123 libkernel and 69 libc tests pass, including `guest_system_configuration`, `guest_getrlimit`, `guest_kernel_fcntl`, `guest_freebsd_clocks`, `guest_kernel_sys` and `guest_filesystem`. Not built alone on Linux; no title run on Linux.
babyhuey commented 2026-10-13 23:35:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-13T23:35:57Z.


Linux check of the PS5MC chain (Ubuntu 24.04, GCC 13, Release, headless), on main 7a0c838c with #5184, #5185 and this PR merged locally. #5185 conflicted with #5184 only in docs/dev/debt/libkernel.md, and I kept both entries.

  • With #5184 alone: Python fails in _PyImport_InitExternal (RuntimeError).
  • With #5185 too: ioctl: request 0x20006601 on a file is not implemented, fd=5.
  • With this PR as well: Python starts, the Addon Manager finds xbmc.python and the two TMDb scrapers, and the run reaches the headless DisplayWindow throw, as far as a run without a display gets.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6157467923 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5186#issuecomment-6157467923). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-13T23:35:57Z. --- Linux check of the PS5MC chain (Ubuntu 24.04, GCC 13, Release, headless), on `main` 7a0c838c with #5184, #5185 and this PR merged locally. #5185 conflicted with #5184 only in `docs/dev/debt/libkernel.md`, and I kept both entries. - With #5184 alone: Python fails in `_PyImport_InitExternal` (`RuntimeError`). - With #5185 too: `ioctl: request 0x20006601 on a file is not implemented, fd=5`. - With this PR as well: Python starts, the Addon Manager finds `xbmc.python` and the two TMDb scrapers, and the run reaches the headless `DisplayWindow` throw, as far as a run without a display gets.
milescoviello commented 2026-10-14 02:09:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-14T02:09:05Z.


Linux run on current main, now that #5184 and #5185 are merged. Ubuntu 24.04, GCC 13.3, Release, RTX 4070 Ti, PS5MC (PPSA99420) catalog build relinked with --to-intel, 40 s each.

  • main 016db923a: stops 0 s in, ioctl: request 0x20006601 on a file is not implemented, fd=7.
  • main 016db923a with this PR (clean merge): no ioctl error. Kodi initializes its Python engine, loads its skin and is still running at 40 s, when the runner ends it (Exiting the application... on the stop signal).

So on main this PR is the only change PS5MC still needs to start.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159310669 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5186#issuecomment-6159310669). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-14T02:09:05Z. --- Linux run on current `main`, now that #5184 and #5185 are merged. Ubuntu 24.04, GCC 13.3, Release, RTX 4070 Ti, PS5MC (PPSA99420) catalog build relinked with `--to-intel`, 40 s each. - `main` 016db923a: stops 0 s in, `ioctl: request 0x20006601 on a file is not implemented, fd=7`. - `main` 016db923a with this PR (clean merge): no ioctl error. Kodi initializes its Python engine, loads its skin and is still running at 40 s, when the runner ends it (`Exiting the application...` on the stop signal). So on `main` this PR is the only change PS5MC still needs to start. AI-assisted: yes
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5186
No description provided.