Skip to content

std: move getpid to sys::process#153130

Open
joboet wants to merge 1 commit intorust-lang:mainfrom
joboet:move_getpid_sys_process
Open

std: move getpid to sys::process#153130
joboet wants to merge 1 commit intorust-lang:mainfrom
joboet:move_getpid_sys_process

Conversation

@joboet
Copy link
Member

@joboet joboet commented Feb 26, 2026

Part of #117276.

Availability of process IDs is highly correlated with availability of processes, so moving the getpid implementations to sys::process makes a lot of sense (and removes quite some code duplication). The only notable change here is on Hermit, which doesn't have processes but does have getpid. But that always returns 0, so I doubt it is useful. If the change to a panic is problematic we could always copy the stub implementation and return zero ourselves (this also applies to the other single-process platforms).

CC @stlankes @mkroening

@rustbot
Copy link
Collaborator

rustbot commented Feb 26, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 8 candidates

@rustbot rustbot added O-hermit Operating System: Hermit O-SGX Target: SGX O-solid Operating System: SOLID O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-windows Operating system: Windows 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 Feb 26, 2026
#[stable(feature = "unix_ppid", since = "1.27.0")]
pub fn parent_id() -> u32 {
crate::sys::os::getppid()
crate::sys::process::getppid()
Copy link
Contributor

Choose a reason for hiding this comment

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

We can implement getppid on windows, don't know why we do not have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-hermit Operating System: Hermit O-SGX Target: SGX O-solid Operating System: SOLID O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-windows Operating system: Windows 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants