feat(libkernel): implement the remaining termios calls #3781

Merged
YossiYad merged 2 commits from upstream-pr/3781 into main 2026-10-12 20:12:13 +00:00
YossiYad commented 2026-10-11 16:40:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-11T16:40:16Z.


What

Carries screamm's screamm/AnyPS5:feat/libkernel-termios-calls commit from #3723 unchanged onto current main, preserving its author, and adds one follow-up test commit:

  • Implement tcsendbreak, tcdrain, tcflush, tcflow, tcgetpgrp and tcsetpgrp next to the merged tcgetattr/tcsetattr, after FreeBSD 11.4 lib/libc/gen/termios.c. tcflush and tcflow return EINVAL for an out-of-range queue or action before the descriptor is used; every other case fails with the error tcgetattr gives (EBADF, ENOTTY for a file or pipe, EADDRNOTAVAIL for AF_INET, EOPNOTSUPP for other sockets). tcgetpgrp/tcsetpgrp throw on a host pipe above descriptor 2, because FreeBSD answers there with the SIGIO owner, which is not modelled. PS5MC (PPSA99420) and XPSemu (PPSA97358) import all six, as reported in #3723.
  • Extend guest_terminal with a Unix-domain socket pair and a directory descriptor. The original test never reached the EOPNOTSUPP branch or a descriptor that is neither a file nor a pipe: with TerminalError returning EADDRNOTAVAIL for every socket family, or HostPipe treating any non-regular file as a pipe, the original test still passes and the extended one fails.

The library progress moves from 2903/3383 (85.81%) to 2909/3389 (85.84%). The total rises by six because none of the six calls was exported before.

Closes #3723.

Tested

Linux (Bazzite 44, GCC 16.2.1, Ninja, Release, -DBUILD_TESTING=ON), based on main a11c8f7f:

  • Full build, libs, and full ctest: 824 pass, 8 skip, no failures (832 registered tests).
  • guest_terminal passes 10 consecutive runs. This is the first Linux run of the carried commit; the author reported Windows only.
  • The two mutations above were applied to Terminal.cpp one at a time and checked against both the original and the extended test.
  • tools/check_conventions.py --base upstream/main and git diff --check pass.
  • The original author reported Windows testing in #3723. The new test cases were not run on Windows, and no game title was run on this machine.

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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • No new third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4820629362 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3781). Originally posted by [YossiYad](https://github.com/YossiYad) on 2026-10-11T16:40:16Z. --- ### What Carries screamm's `screamm/AnyPS5:feat/libkernel-termios-calls` commit from #3723 unchanged onto current `main`, preserving its author, and adds one follow-up test commit: - Implement `tcsendbreak`, `tcdrain`, `tcflush`, `tcflow`, `tcgetpgrp` and `tcsetpgrp` next to the merged `tcgetattr`/`tcsetattr`, after FreeBSD 11.4 `lib/libc/gen/termios.c`. `tcflush` and `tcflow` return `EINVAL` for an out-of-range queue or action before the descriptor is used; every other case fails with the error `tcgetattr` gives (`EBADF`, `ENOTTY` for a file or pipe, `EADDRNOTAVAIL` for `AF_INET`, `EOPNOTSUPP` for other sockets). `tcgetpgrp`/`tcsetpgrp` throw on a host pipe above descriptor 2, because FreeBSD answers there with the SIGIO owner, which is not modelled. PS5MC (PPSA99420) and XPSemu (PPSA97358) import all six, as reported in #3723. - Extend `guest_terminal` with a Unix-domain socket pair and a directory descriptor. The original test never reached the `EOPNOTSUPP` branch or a descriptor that is neither a file nor a pipe: with `TerminalError` returning `EADDRNOTAVAIL` for every socket family, or `HostPipe` treating any non-regular file as a pipe, the original test still passes and the extended one fails. The library progress moves from 2903/3383 (85.81%) to 2909/3389 (85.84%). The total rises by six because none of the six calls was exported before. Closes #3723. ### Tested Linux (Bazzite 44, GCC 16.2.1, Ninja, Release, `-DBUILD_TESTING=ON`), based on `main` `a11c8f7f`: - Full build, `libs`, and full `ctest`: 824 pass, 8 skip, no failures (832 registered tests). - `guest_terminal` passes 10 consecutive runs. This is the first Linux run of the carried commit; the author reported Windows only. - The two mutations above were applied to `Terminal.cpp` one at a time and checked against both the original and the extended test. - `tools/check_conventions.py --base upstream/main` and `git diff --check` pass. - The original author reported Windows testing in #3723. The new test cases were not run on Windows, and no game title was run on this machine. ### 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 - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] No new third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-11 16:40:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T16:40:55Z.


Progress report (3e0e01f → 0c1fa50)

📈 System libraries: 86.39% (+0.03%, +6 implemented functions)

✅ 6 implemented
Library Name
libkernel tcdrain_nid_postfix
libkernel tcflow_nid_postfix
libkernel tcflush_nid_postfix
libkernel tcgetpgrp_nid_postfix
libkernel tcsendbreak_nid_postfix
libkernel tcsetpgrp_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111270986 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3781#issuecomment-6111270986). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T16:40:55Z. --- <!-- progress-report --> ### Progress report (3e0e01f → 0c1fa50) 📈 **System libraries**: 86.39% (+0.03%, +6 implemented functions) <details> <summary>✅ 6 implemented</summary> | Library | Name | | - | - | | libkernel | `tcdrain_nid_postfix` | | libkernel | `tcflow_nid_postfix` | | libkernel | `tcflush_nid_postfix` | | libkernel | `tcgetpgrp_nid_postfix` | | libkernel | `tcsendbreak_nid_postfix` | | libkernel | `tcsetpgrp_nid_postfix` | </details>
oneandonlydean commented 2026-10-11 23:16:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:16:47Z.


Conflicts with main in docs/dev/TechnicalDebt.md; please rebase.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115003437 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3781#issuecomment-6115003437). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T23:16:47Z. --- Conflicts with main in `docs/dev/TechnicalDebt.md`; please rebase.
adriadam10 commented 2026-10-12 19:59:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T19:59:25Z.


Rebased onto current main: the TechnicalDebt entry now lives in docs/dev/debt/libkernel.md (entries moved there in 342a8c459), under "Functional"; no code changes. Checked against FreeBSD termios.c (tcflush/tcflow EINVAL before the ioctl, tcsendbreak failing on TIOCSBRK before the pause, pgrp calls via ioctl); guest_terminal passes locally on Linux and the new cases fail without the implementation. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6131635133 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3781#issuecomment-6131635133). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T19:59:25Z. --- Rebased onto current `main`: the TechnicalDebt entry now lives in `docs/dev/debt/libkernel.md` (entries moved there in 342a8c459), under "Functional"; no code changes. Checked against FreeBSD `termios.c` (tcflush/tcflow `EINVAL` before the ioctl, `tcsendbreak` failing on `TIOCSBRK` before the pause, pgrp calls via ioctl); `guest_terminal` passes locally on Linux and the new cases fail without the implementation. Merging once CI is green.
github-actions[bot] commented 2026-10-12 20:06:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T20:06:45Z.


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
#4622 docs/dev/debt/libkernel.md L94-95
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6131743183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3781#issuecomment-6131743183). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T20:06:45Z. --- <!-- 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 | |---|---|---|---| | #4622 | `docs/dev/debt/libkernel.md` [L94-95](https://github.com/boykopovar/AnyPS5/blob/01422156878b455efc0bbfaa33cd5b0cd28c2587/docs/dev/debt/libkernel.md#L94-L95) | | |
adriadam10 commented 2026-10-12 20:12:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T20:12:10Z.


Checked against FreeBSD termios.c (tcflush/tcflow EINVAL before the ioctl, tcsendbreak failing on TIOCSBRK before the pause, pgrp calls via ioctl); guest_terminal passes locally on Linux on the rebased head. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6131822040 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3781#issuecomment-6131822040). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T20:12:10Z. --- Checked against FreeBSD `termios.c` (tcflush/tcflow `EINVAL` before the ioctl, `tcsendbreak` failing on `TIOCSBRK` before the pause, pgrp calls via ioctl); `guest_terminal` passes locally on Linux on the rebased head. Merging once CI is green.
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!3781
No description provided.