Skip to content

Handle zero foreground process groups on non-Linux targets - #1710

Open
jadenfix wants to merge 1 commit into
bytecodealliance:mainfrom
jadenfix:fix/tcgetpgrp-zero-libc
Open

jadenfix wants to merge 1 commit into
bytecodealliance:mainfrom
jadenfix:fix/tcgetpgrp-zero-libc

Conversation

@jadenfix

Copy link
Copy Markdown

On macOS a newly opened pseudo-terminal can return zero from tcgetpgrp. The libc backend currently passes that to Pid::from_raw_unchecked, which requires a positive value. Apply the existing Linux zero-to-OPNOTSUPP handling on other libc targets too, and update the public documentation and Apple regression expectation.

Fixes #1678.

Validation on macOS:

  • The existing pgrp_pseudoterminal test panics on the baseline; it passes after the fix.
  • cargo test --features=all-apis: 215 unit/integration tests and 23 doctests passed, 3 tests intentionally ignored.
  • Focused release process-group tests, cargo check --no-default-features --features=pty,termios, and cargo fmt --all -- --check passed.
  • A separate public consumer checked a newly opened PTY (OPNOTSUPP), /dev/null (NOTTY), and an actual controlling terminal in a child process (the expected positive process group).
  • Ordinary all-API documentation builds. An additional RUSTDOCFLAGS="-D warnings" check reports the same 13 existing errors on the clean baseline and candidate. Other operating systems and Rust 1.65 were not run locally.

Prepared with Codex assistance and independently reviewed by a separate Codex agent. No human review is claimed.

@xtqqczze

Copy link
Copy Markdown
Contributor

No human review is claimed.

@jadenfix Could you please review your own contribution carefully before requesting human review?

@jadenfix

Copy link
Copy Markdown
Author

Thanks for the reminder. I've personally reviewed this contribution.

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.

rustix::termios::tcgetpgrp is unsound on macOS

2 participants