Skip to content

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

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
YossiYad:carry/libkernel-termios-calls
Oct 12, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
YossiYad:carry/libkernel-termios-calls

Conversation

@YossiYad

Copy link
Copy Markdown
Contributor

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 libkernel: tcsendbreak, tcdrain, tcflush, tcflow, tcgetpgrp and tcsetpgrp are absent (PS5MC, XPSemu); fix branch ready #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 libkernel: tcsendbreak, tcdrain, tcflush, tcflow, tcgetpgrp and tcsetpgrp are absent (PS5MC, XPSemu); fix branch ready #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

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 11, 2026
@YossiYad
YossiYad force-pushed the carry/libkernel-termios-calls branch from f875b40 to 99fb339 Compare October 11, 2026 22:20
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 11, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

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

screamm and others added 2 commits October 12, 2026 21:48
Adds tcsendbreak (vXE-dIUIZlE), tcdrain (brGGJWsZauw), tcflush
(FxHW5NuEXsY), tcflow (OG8xRaGIpqk), tcgetpgrp (5OEl1mRhUm0) and
tcsetpgrp (YMuesZTyTl4) next to tcgetattr and tcsetattr in
File/src/Terminal.cpp. The NIDs come from tools/nid_names.py and match
aerolib.csv (zecoxao/sce_symbols 2883963a).

They follow FreeBSD 11.4 lib/libc/gen/termios.c (8c639945), which
implements each one over a terminal ioctl: tcflush returns EINVAL for a
queue other than TCIFLUSH, TCOFLUSH or TCIOFLUSH and tcflow for an
action outside TCOOFF..TCION before the descriptor is used; every other
call fails with the error the merged tcgetattr gives (EBADF for a closed
descriptor, ENOTTY for a file or pipe, EADDRNOTAVAIL or EOPNOTSUPP for a
socket, per soo_ioctl and in_control/in6_control). tcsendbreak fails on
TIOCSBRK before its 0.4 s pause, and tcflow's TCIOFF/TCION fail in
tcgetattr. FreeBSD's pipe_ioctl answers TIOCGPGRP/TIOCSPGRP on a pipe or
FIFO with the SIGIO owner, which is not modelled, so tcgetpgrp and
tcsetpgrp throw on a host pipe above descriptor 2.

Titles (homebrew catalog boykopovar#1578), predicted stops from registry order:
- PS5MC PPSA99420 imports tcsendbreak (442), tcdrain (443), tcflush
  (444), tcflow (445), tcgetpgrp (462) and tcsetpgrp (463); once pause
  and setrlimit are in, it stops at
  "FAIL: unresolved ELF import vXE-dIUIZlE from libkernel.prx".
- XPSemu PPSA97358 imports tcsendbreak (214), its first uncovered import
  after execv, sigwait, setrlimit, mlockall, setuid and getopt:
  "FAIL: unresolved ELF import vXE-dIUIZlE from libkernel.prx".

guest_terminal covers each call over stdin, stdout, stderr, a file, both
pipe ends and an AF_INET socket, the EINVAL cases (also on -1), and
EBADF for -1, a closed socket, a closed pipe and a closed file.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the carry/libkernel-termios-calls branch from 99fb339 to 0c1fa50 Compare October 12, 2026 19:59
@adriadam10

Copy link
Copy Markdown
Collaborator

Rebased onto current main: the TechnicalDebt entry now lives in docs/dev/debt/libkernel.md (entries moved there in 342a8c4), 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

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

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

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@github-actions github-actions Bot mentioned this pull request Oct 12, 2026
10 tasks done
@adriadam10

Copy link
Copy Markdown
Collaborator

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.

@adriadam10
adriadam10 merged commit 198e022 into boykopovar:main Oct 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libkernel: tcsendbreak, tcdrain, tcflush, tcflow, tcgetpgrp and tcsetpgrp are absent (PS5MC, XPSemu); fix branch ready

4 participants