[FEATURE] Provide termios parameters and mediated terminal attributes #20

Open
opened 2026-10-29 22:52:02 +01:00 by erikinkinen · 1 comment
Owner

Problem and motivation

C programs need to inspect and change their terminal settings. The existing
identification and window calls do not expose termios, and the native six mode
bits cannot represent its control characters, queue actions or read timing.

Proposed behavior and scope

Define the namespaced C/Rust termios parameter object, matching flag and character
constants, and all four caller-owned speed accessors. These functions operate on
the supplied object without acquiring a terminal or changing a device.

Add mediated attribute and action calls after the native PTY supplies their real
semantics. This includes configurable canonical characters and records,
noncanonical minimum/time reads, input/output processing, drain/flush and flow,
break handling, and authenticated foreground-group behavior. Distinguish virtual
PTY settings from hardware effects. Use POSIX.1-2024 as the semantic reference;
conventional aliases still depend on compatibility startup and signal dispatch.

Authority, security and reliability

Parameter values and speed codes carry no authority. Local accessors preserve
unrelated caller state and use only the existing thread errno convention.
Terminal operations use the retained descriptor description and its explicitly
granted native control view through Posixd. Keep STATE, MODE and other operation
rights narrow; new attribute write effects need an explicit grant rather than
broadening old views. A byte-only peer receives no implicit control authority.

Retain original owners through queued changes, interruption, alias replacement,
revocation and cleanup. Drain means actual output progress, not a synthetic
success. Unknown effects or retirement prevent replay and ordinary reuse.
Foreground IDs alone cannot authorize signaling another process group.

Acceptance criteria

  • Publish the complete parameter layout, declared constants and four local
    speed accessors with C/Rust agreement and unrelated-state/errno preservation.
  • Implement real native attributes and configurable canonical control
    characters, including EOF records and lossless mode transitions.
  • Connect native attribute observation/replacement to the existing C runtime
    and Posixd bridge with exact framing and per-operation rights.
  • Implement required drain/flush, flow, break and noncanonical read timing
    without fabricated device effects or arbitrary buffer limits.
  • Bind foreground/session behavior to authenticated process ownership and
    signal delivery; preserve cancellation and original-call retirement.
  • Cover malformed inputs, missing rights, stale views, concurrent aliases,
    interrupted actions and partial failure with independent controls.
  • Demonstrate the original C/native workload, including restoration and
    byte-only peers, then exercise required imported-tool behavior.
  • Update headers, companion/export guards, component documentation, technical
    manual and API references while keeping conventional aliases explicit.

Alternatives and tradeoffs

Projecting the old mode mask into a full termios object would invent unsupported
state. Direct provider calls would bypass descriptor lifetime and permission
checks. Land the caller-owned parameter dependency first, then add genuine native
semantics and the mediated operations together.

Tracking and rollout

Build on native terminal controls
and C identification and windows.
Track the complete scope in Phase 6
and the existing Cstd,
Posixd and
Integration PRs.

## Problem and motivation C programs need to inspect and change their terminal settings. The existing identification and window calls do not expose termios, and the native six mode bits cannot represent its control characters, queue actions or read timing. ## Proposed behavior and scope Define the namespaced C/Rust termios parameter object, matching flag and character constants, and all four caller-owned speed accessors. These functions operate on the supplied object without acquiring a terminal or changing a device. Add mediated attribute and action calls after the native PTY supplies their real semantics. This includes configurable canonical characters and records, noncanonical minimum/time reads, input/output processing, drain/flush and flow, break handling, and authenticated foreground-group behavior. Distinguish virtual PTY settings from hardware effects. Use POSIX.1-2024 as the semantic reference; conventional aliases still depend on compatibility startup and signal dispatch. ## Authority, security and reliability Parameter values and speed codes carry no authority. Local accessors preserve unrelated caller state and use only the existing thread errno convention. Terminal operations use the retained descriptor description and its explicitly granted native control view through Posixd. Keep STATE, MODE and other operation rights narrow; new attribute write effects need an explicit grant rather than broadening old views. A byte-only peer receives no implicit control authority. Retain original owners through queued changes, interruption, alias replacement, revocation and cleanup. Drain means actual output progress, not a synthetic success. Unknown effects or retirement prevent replay and ordinary reuse. Foreground IDs alone cannot authorize signaling another process group. ## Acceptance criteria - [x] Publish the complete parameter layout, declared constants and four local speed accessors with C/Rust agreement and unrelated-state/errno preservation. - [ ] Implement real native attributes and configurable canonical control characters, including EOF records and lossless mode transitions. - [ ] Connect native attribute observation/replacement to the existing C runtime and Posixd bridge with exact framing and per-operation rights. - [ ] Implement required drain/flush, flow, break and noncanonical read timing without fabricated device effects or arbitrary buffer limits. - [ ] Bind foreground/session behavior to authenticated process ownership and signal delivery; preserve cancellation and original-call retirement. - [ ] Cover malformed inputs, missing rights, stale views, concurrent aliases, interrupted actions and partial failure with independent controls. - [ ] Demonstrate the original C/native workload, including restoration and byte-only peers, then exercise required imported-tool behavior. - [ ] Update headers, companion/export guards, component documentation, technical manual and API references while keeping conventional aliases explicit. ## Alternatives and tradeoffs Projecting the old mode mask into a full termios object would invent unsupported state. Direct provider calls would bypass descriptor lifetime and permission checks. Land the caller-owned parameter dependency first, then add genuine native semantics and the mediated operations together. ## Tracking and rollout Build on [native terminal controls](https://git.erikinkinen.fi/erix/ttyd/issues/5) and [C identification and windows](https://git.erikinkinen.fi/erix/lib-cstd/issues/19). Track the complete scope in [Phase 6](https://git.erikinkinen.fi/erix/integration/issues/65) and the existing [Cstd](https://git.erikinkinen.fi/erix/lib-cstd/pulls/3), [Posixd](https://git.erikinkinen.fi/erix/posixd/pulls/5) and [Integration](https://git.erikinkinen.fi/erix/integration/pulls/12) PRs.
Author
Owner

The caller-owned parameter API is published, with the matching C/Rust layout, constants and four speed accessors. Each call touches only its selected field, preserving unrelated bytes and errno. Integration selects the original assembly and C probe; the manual describes the contract. Native attributes and actions remain open.

The caller-owned parameter API is [published](https://git.erikinkinen.fi/erix/lib-cstd/commit/9409ff854a8fcf64a7fef8aa44806218b501fc6a), with the matching C/Rust layout, constants and four speed accessors. Each call touches only its selected field, preserving unrelated bytes and errno. [Integration](https://git.erikinkinen.fi/erix/integration/commit/a75be72efe63145c3a25e5e38a157f0d205639aa) selects the original assembly and C probe; the [manual](https://git.erikinkinen.fi/erix/docs/commit/93e2c1a2980c2c948aaf20fa94b45fd8c0eb2d6c) describes the contract. Native attributes and actions remain open.
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:34:41 +01:00
Sign in to join this conversation.
No milestone
No project
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.

Dependencies

No dependencies set

Reference
erix/lib-cstd#20
No description provided.