Skip to content

use PIDFD_GET_INFO ioctl when available - #150412

Merged
bors merged 1 commit into
rust-lang:mainfrom
the8472:pidfd-spawn
Jan 6, 2026
Merged

use PIDFD_GET_INFO ioctl when available#150412
bors merged 1 commit into
rust-lang:mainfrom
the8472:pidfd-spawn

Conversation

@the8472

@the8472the8472 commented Dec 26, 2025

Copy link
Copy Markdown
Member

This way using pidfd_spawnp won't have to rely on procfs, avoiding an unpleasant edge-case where the child is spawned but we can't get the pid. And pidfd.{try_}wait will be able to return the exit status even after a process has been reaped. At least on newer kernels.

Tracking issue: #82971

@the8472the8472 added the O-linux Operating system: Linux label Dec 26, 2025
@rustbotrustbot added O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 26, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

r? @jhpratt

rustbot has assigned @jhpratt.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@jhpratt

Copy link
Copy Markdown
Member

I'm not familiar with this area of code.

r? libs

@rustbot

Copy link
Copy Markdown
Collaborator

No reviewers could be found from initial request libs
This repo may be misconfigured.
Use r? to specify someone else to assign.

@jhpratt

Copy link
Copy Markdown
Member

Attempting to re-roll again

r? libs

@rustbotrustbot assigned tgross35 and unassigned jhprattJan 4, 2026

@tgross35tgross35 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small suggestions but LGTM.

Cc @cuviper if you'd like to take a second look, since I assume you're more up on the latest pidfd developments than I am.

View changes since this review

Comment threadlibrary/std/src/sys/pal/unix/linux/pidfd.rs
Comment threadlibrary/std/src/sys/pal/unix/linux/pidfd.rs Outdated
@the8472

Copy link
Copy Markdown
MemberAuthor

@bors r=tgross35

@bors

bors commented Jan 5, 2026

Copy link
Copy Markdown
Collaborator

📌 Commit bf2308f has been approved by tgross35

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 5, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 5, 2026
use PIDFD_GET_INFO ioctl when available
This way using pidfd_spawnp won't have to rely on procfs, avoiding an unpleasant edge-case where the child is spawned but we can't get the pid. And pidfd.{try_}wait will be able to return the exit status even after a process has been reaped. At least on newer kernels.
Tracking issue: rust-lang#82971
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 5, 2026
use PIDFD_GET_INFO ioctl when available
This way using pidfd_spawnp won't have to rely on procfs, avoiding an unpleasant edge-case where the child is spawned but we can't get the pid. And pidfd.{try_}wait will be able to return the exit status even after a process has been reaped. At least on newer kernels.
Tracking issue: rust-lang#82971
bors added a commit that referenced this pull request Jan 5, 2026
Rollup of 3 pull requests
Successful merges:
- #150412 (use PIDFD_GET_INFO ioctl when available)
- #150668 (Unix implementation for stdio set/take/replace)
- #150702 (`rust-analyzer` subtree update)
r? `@ghost`
`@rustbot` modify labels: rollup
@matthiaskrgr

Copy link
Copy Markdown
Member

@bors r-

#150716 (comment)

@borsbors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 5, 2026
@the8472
the8472force-pushed the pidfd-spawn branch 2 times, most recently from 5eba1bb to 975fda9CompareJanuary 6, 2026 00:05
@the8472

Copy link
Copy Markdown
MemberAuthor

Added additional cfgs. Locally it passes x check for ohos and android.

@bors r=tgross35

@borsbors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 6, 2026
This way using pidfd_spawnp won't have to rely on procfs, avoiding an unpleasant edge-case
where the child is spawned but we can't get the pid.
And `pidfd.{try_}wait` will be able to return the exit status even after a process has been reaped.
At least on newer kernels.
@the8472

Copy link
Copy Markdown
MemberAuthor

@bors try jobs=arm-android

rust-borsBot added a commit that referenced this pull request Jan 6, 2026
use PIDFD_GET_INFO ioctl when available
try-job: arm-android
@rust-bors

This comment has been minimized.

@rust-bors

rust-borsBot commented Jan 6, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: db2c05c (db2c05c00f9ce5afe201427e41827cc903758986, parent: 4fa80a5e733e2202d7ca4c203c2fdfda41cfe7dc)

@the8472

Copy link
Copy Markdown
MemberAuthor

@bors r=tgross35 rollup=iffy

@bors

bors commented Jan 6, 2026

Copy link
Copy Markdown
Collaborator

📌 Commit fa4a62b has been approved by tgross35

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 6, 2026
Zalathar added a commit to Zalathar/rust that referenced this pull request Jan 6, 2026
use PIDFD_GET_INFO ioctl when available
This way using pidfd_spawnp won't have to rely on procfs, avoiding an unpleasant edge-case where the child is spawned but we can't get the pid. And pidfd.{try_}wait will be able to return the exit status even after a process has been reaped. At least on newer kernels.
Tracking issue: rust-lang#82971
@ZalatharZalathar mentioned this pull request Jan 6, 2026
bors added a commit that referenced this pull request Jan 6, 2026
Rollup of 8 pull requests
Successful merges:
- #144113 (Impls and impl items inherit `dead_code` lint level of the corresponding traits and trait items)
- #149880 (rustc_codegen_llvm: update alignment for double on AIX)
- #150412 (use PIDFD_GET_INFO ioctl when available)
- #150668 (Unix implementation for stdio set/take/replace)
- #150670 (THIR pattern building: Move all `thir::Pat` creation into `rustc_mir_build::thir::pattern`)
- #150695 (MGCA: pretty printing for struct expressions and tuple calls )
- #150698 (Improve comment clarity in candidate_may_shadow)
- #150706 (Update wasm-component-ld)
r? `@ghost`
`@rustbot` modify labels: rollup
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 6, 2026
use PIDFD_GET_INFO ioctl when available
This way using pidfd_spawnp won't have to rely on procfs, avoiding an unpleasant edge-case where the child is spawned but we can't get the pid. And pidfd.{try_}wait will be able to return the exit status even after a process has been reaped. At least on newer kernels.
Tracking issue: rust-lang#82971
bors added a commit that referenced this pull request Jan 6, 2026
…uwer
Rollup of 11 pull requests
Successful merges:
- #144113 (Impls and impl items inherit `dead_code` lint level of the corresponding traits and trait items)
- #148339 (naked functions: emit `.private_extern` on macos)
- #149880 (rustc_codegen_llvm: update alignment for double on AIX)
- #150122 (Refactor function names of `rustc_ast_lowering`)
- #150412 (use PIDFD_GET_INFO ioctl when available)
- #150670 (THIR pattern building: Move all `thir::Pat` creation into `rustc_mir_build::thir::pattern`)
- #150695 (MGCA: pretty printing for struct expressions and tuple calls )
- #150698 (Improve comment clarity in candidate_may_shadow)
- #150706 (Update wasm-component-ld)
- #150707 (Fix ICE when transmute Assume field is invalid)
- #150708 (Enable merge queue in new bors)
r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jan 6, 2026
Rollup of 11 pull requests
Successful merges:
- #144113 (Impls and impl items inherit `dead_code` lint level of the corresponding traits and trait items)
- #148339 (naked functions: emit `.private_extern` on macos)
- #149880 (rustc_codegen_llvm: update alignment for double on AIX)
- #150122 (Refactor function names of `rustc_ast_lowering`)
- #150412 (use PIDFD_GET_INFO ioctl when available)
- #150670 (THIR pattern building: Move all `thir::Pat` creation into `rustc_mir_build::thir::pattern`)
- #150695 (MGCA: pretty printing for struct expressions and tuple calls )
- #150698 (Improve comment clarity in candidate_may_shadow)
- #150706 (Update wasm-component-ld)
- #150707 (Fix ICE when transmute Assume field is invalid)
- #150708 (Enable merge queue in new bors)
r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jan 6, 2026
…uwer
Rollup of 10 pull requests
Successful merges:
- #144113 (Impls and impl items inherit `dead_code` lint level of the corresponding traits and trait items)
- #149880 (rustc_codegen_llvm: update alignment for double on AIX)
- #150122 (Refactor function names of `rustc_ast_lowering`)
- #150412 (use PIDFD_GET_INFO ioctl when available)
- #150670 (THIR pattern building: Move all `thir::Pat` creation into `rustc_mir_build::thir::pattern`)
- #150695 (MGCA: pretty printing for struct expressions and tuple calls )
- #150698 (Improve comment clarity in candidate_may_shadow)
- #150706 (Update wasm-component-ld)
- #150707 (Fix ICE when transmute Assume field is invalid)
- #150708 (Enable merge queue in new bors)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 3b0d35f into rust-lang:mainJan 6, 2026
12 checks passed
@rustbotrustbot added this to the 1.94.0 milestone Jan 6, 2026
rust-timer added a commit that referenced this pull request Jan 6, 2026
Rollup merge of #150412 - the8472:pidfd-spawn, r=tgross35
use PIDFD_GET_INFO ioctl when available
This way using pidfd_spawnp won't have to rely on procfs, avoiding an unpleasant edge-case where the child is spawned but we can't get the pid. And pidfd.{try_}wait will be able to return the exit status even after a process has been reaped. At least on newer kernels.
Tracking issue: #82971
@zmodem

Copy link
Copy Markdown
Contributor

We're seeing test failures, hitting the panic! in test_command_pidfd during testing:

 thread 'sys::pal::unix::linux::pidfd::tests::test_command_pidfd' (295684) panicked at library/std/src/sys/pal/unix/linux/pidfd/tests.rs:66:23:
unexpected error getting pid from pidfd: Inappropriate ioctl for device (os error 25)

I think that means ioctl returned ENOTTY. This is with a Linux 6.8.0 kernel, which might be too old for this feature(?). But shouldn't the test handle that gracefully somehow?

@the8472

Copy link
Copy Markdown
MemberAuthor

It's supposed to yeah but it's only checking for EINVAL and not ENOTTY, I'll submit a fix.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 14, 2026
also handle ENOTTY ioctl errors when checking pidfd -> pid support
Otherwise the std testsuite fails on older kernels.
Reported in rust-lang#150412 (comment)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jan 14, 2026
also handle ENOTTY ioctl errors when checking pidfd -> pid support
Otherwise the std testsuite fails on older kernels.
Reported in rust-lang#150412 (comment)
rust-timer added a commit that referenced this pull request Jan 14, 2026
Rollup merge of #151072 - fix-pidfd-ioctl, r=jhpratt
also handle ENOTTY ioctl errors when checking pidfd -> pid support
Otherwise the std testsuite fails on older kernels.
Reported in #150412 (comment)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-linuxOperating system: LinuxO-unixOperating system: Unix-likeS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@the8472@rustbot@jhpratt@bors@matthiaskrgr@zmodem@tgross35