[Kernel/POSIX] Distinguish terminals from character devices - #1104
Open
brandonpayton wants to merge 1 commit into
Open
[Kernel/POSIX] Distinguish terminals from character devices#1104brandonpayton wants to merge 1 commit into
brandonpayton wants to merge 1 commit into
Conversation
Character-special mode is broader than terminal identity. Kandelo encoded host terminal stdio and virtual devices such as /dev/null, framebuffer, audio, and DRM with FileType::CharDevice, so terminal probes could mistake every virtual character device for an interactive terminal. In particular, musl implements isatty() with TIOCGWINSZ, causing redirected Bash output to observe false terminal behavior. Derive terminal identity from the open file description: dedicated PTY master/slave types are terminals, and legacy host stdio is a terminal only when its stable canonical stdio path and host handle agree. Reuse that classification across isatty, termios, ioctl namespace gating, and fpathconf. Keep generic FION* requests ahead of terminal gating and preserve device-specific ioctl dispatch. This is a compatible semantic correction under ABI 42. It changes no syscall numbers, marshalling, exported signatures, structure layouts, generated bindings, or VFS ABI metadata, so existing binaries remain valid and need no rebuild. Validation: - focused non-terminal character-device terminal matrix, including the exact musl TIOCGWINSZ isatty path: 1 passed - full kernel unit suite: 1,253 passed - ABI snapshot and generated bindings check - git diff --check
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Kandelo used the broad character-device file type for both interactive terminals and virtual devices such as /dev/null, framebuffer, audio, and DRM. Terminal checks therefore treated all of those devices as interactive. For example, musl implements isatty() with TIOCGWINSZ, so a program writing to /dev/null could incorrectly change its behavior as though output were attached to a terminal.
What changed
ABI
No ABI bump is needed. This corrects syscall semantics without changing syscall numbers, marshalling, exported signatures, structure layouts, generated bindings, or VFS ABI metadata. Existing ABI 42 programs and bottles remain valid.
Validation
Not run
The vendored libc, POSIX, and Sortix suites do not currently contain matching terminal/isatty cases. Product-level Node and Chromium Homebrew validation is running in the parent migration workstream.