Skip to content

fix: checked pid conversion, remaining call sites (follow-up to #180, #179) - #182

Merged
chaodu-agent merged 1 commit into
mainfrom
fix/179-clean-proc-pid
Nov 24, 2026
Merged

chaodu-agent merged 1 commit into
mainfrom
fix/179-clean-proc-pid

Conversation

@chaodu-agent

Copy link
Copy Markdown
Contributor

Refs #179
Refs #180

#180 (squash-merged to main as 203bbdd) fixed the checked pid conversion on the main path. The pid is now converted with checked_pid, so debug and release builds give the same answer for pids that do not fit in i32. This PR is the follow-up for the call sites that #180 did not cover.

Remaining call sites covered

  • poc/reverse-attach-linux/src/jobs/mod.rs, shell_exited: the waitid call now receives the pid from crate::proc::checked_pid. A pid that names no process returns true, the same answer the function already gives for ECHILD. Before this change the raw u32 was passed straight to waitid.

Tests

New test: checked_pid_keeps_valid_pids_and_rejects_the_rest in poc/reverse-attach-linux/src/proc_tests.rs. It checks that 1 and i32::MAX are kept, and that 0, 2^31, and u32::MAX are rejected.

Results for head c775a6e74e7735a72c15bd0eb7805b92ac8ad56b, run in poc/reverse-attach-linux:

  • cargo test (debug): 604 passed, 0 failed, 17 ignored
  • cargo test --release: 604 passed, 0 failed, 17 ignored
  • Combined: 1208 passed, 0 failed, 34 ignored
  • cargo fmt --check: no diagnostics
  • cargo clippy -- -D warnings: no warnings

No Swift files changed.

shell_exited passed a u32 pid straight to waitid. A value that does not
fit in i32, or is zero, now returns true, the same answer the ECHILD
path already gives for a child that is gone. Valid pids are unchanged.

Adds checked_pid_keeps_valid_pids_and_rejects_the_rest, which covers
1, i32::MAX, 0, 2147483648 and u32::MAX.

Commands run on a Linux arm64 host, in a fresh clone of the branch:
- cargo test
- cargo test --release
- cargo fmt --check
- cargo clippy -- -D warnings
@chaodu-agent
chaodu-agent merged commit a717a28 into main Nov 24, 2026
14 of 15 checks passed
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