Skip to content

Support terminal foreground process groups - #1714

Merged
Weidong Cui (wdcui) merged 4 commits into
uliteboxfrom
wdcui/ulitebox/tty-job-control
Oct 26, 2026
Merged

Weidong Cui (wdcui) merged 4 commits into
uliteboxfrom
wdcui/ulitebox/tty-job-control

Conversation

@wdcui

@wdcui Weidong Cui (wdcui) commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

This PR adds terminal job control. The broker core now tracks a foreground process group for the controlling terminal's session and sends terminal events such as Ctrl-C to that group instead of the first root's group. Processes in the session query and change it through new process-group requests that take a handle to the terminal and report generic errors. The Linux shim implements tcgetpgrp, tcsetpgrp, and tcgetsid on top, mapping those errors to Linux errnos. Unit and end-to-end tests are included.

Weidong Cui (wdcui) and others added 4 commits October 26, 2026 13:08
The broker core now owns the controlling terminal's job-control state, like
a kernel's terminal layer: the terminal controls the first root process's
session and delivers its events to a foreground process group that
processes in the session can query and change. Terminal endpoints keep
handling only terminal I/O controls. The Linux shim implements TIOCGPGRP,
TIOCSPGRP, and TIOCGSID on top, mapping the broker's generic errors to
Linux errnos.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1172b488-1351-40c1-a6d0-32f5277af568
The foreground process group is session state, not a terminal operation.
Get and set it through ProcessGroupRequest with a handle to the controlling
terminal, reporting guest-visible failures as ProcessGroupError, so terminal
endpoints handle only I/O. The shim maps the job-control ioctls onto the new
LiteBox process API.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1172b488-1351-40c1-a6d0-32f5277af568
An endpoint may post events while attaching, and posting takes the
process tree lock. Also make the job-control fixture's interrupt check
independent of the inherited SIGINT disposition and mask.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1172b488-1351-40c1-a6d0-32f5277af568
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1172b488-1351-40c1-a6d0-32f5277af568
@wdcui
Weidong Cui (wdcui) force-pushed the wdcui/ulitebox/tty-job-control branch from 7788457 to 3633a5d Compare October 26, 2026 20:11
@wdcui
Weidong Cui (wdcui) added this pull request to the merge queue Oct 26, 2026
@github-actions

Copy link
Copy Markdown

🤖 SemverChecks 🤖 ⚠️ Potential breaking API changes detected ⚠️

Click for details
--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/enum_variant_added.ron

Failed in:
  variant ProcessError:NotControllingTerminal in /home/runner/work/litebox/litebox/litebox/src/process.rs:64
  variant ProcessError:NoSuchProcessGroup in /home/runner/work/litebox/litebox/litebox/src/process.rs:67
  variant ProcessError:NotInSession in /home/runner/work/litebox/litebox/litebox/src/process.rs:70

--- failure enum_discriminants_undefined_non_unit_variant: enum's variants no longer have defined discriminants due to non-unit variant ---

Description:
An enum's variants no longer have well-defined discriminant values due to a tuple or struct variant in the enum. This breaks downstream code that accesses discriminants via a numeric cast like `as isize`.
        ref: https://doc.rust-lang.org/reference/items/enumerations.html#assigning-discriminant-values
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/enum_discriminants_undefined_non_unit_variant.ron

Failed in:
  enum ProcessGroupResponse in /home/runner/work/litebox/litebox/litebox_broker_protocol/src/message.rs:630

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.51.0/src/lints/enum_variant_added.ron

Failed in:
  variant ProcessGroupResponse:GetForegroundGroup in /home/runner/work/litebox/litebox/litebox_broker_protocol/src/message.rs:636
  variant ProcessGroupResponse:SetForegroundGroup in /home/runner/work/litebox/litebox/litebox_broker_protocol/src/message.rs:638
  variant ProcessGroupResponse:Failed in /home/runner/work/litebox/litebox/litebox_broker_protocol/src/message.rs:642
  variant ProcessGroupRequest:GetForegroundGroup in /home/runner/work/litebox/litebox/litebox_broker_protocol/src/message.rs:390
  variant ProcessGroupRequest:SetForegroundGroup in /home/runner/work/litebox/litebox/litebox_broker_protocol/src/message.rs:399

Merged via the queue into ulitebox with commit d6126b2 Oct 26, 2026
11 checks passed
@wdcui
Weidong Cui (wdcui) deleted the wdcui/ulitebox/tty-job-control branch October 26, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant