Skip to content

Commit

Permalink
Rollup merge of rust-lang#46092 - sfackler:ppid, r=alexcrichton
Browse files Browse the repository at this point in the history
Add process::parent_id

I have this as a Unix-only API since it seems like Windows doesn't have
a similar API.

r? @alexcrichton
  • Loading branch information
kennytm committed Nov 20, 2017
2 parents 3b1cf4d + 1e42d5f commit fe2ec73
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libstd/sys/redox/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,7 @@ pub fn exit(code: i32) -> ! {
pub fn getpid() -> u32 {
syscall::getpid().unwrap() as u32
}

pub fn getppid() -> u32 {
syscall::getppid().unwrap() as u32
}
6 changes: 6 additions & 0 deletions src/libstd/sys/unix/ext/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,9 @@ impl IntoRawFd for process::ChildStderr {
self.into_inner().into_fd().into_raw()
}
}

/// Returns the OS-assigned process identifier associated with this process's parent.
#[unstable(feature = "unix_ppid", issue = "46104")]
pub fn parent_id() -> u32 {
::sys::os::getppid()
}
4 changes: 4 additions & 0 deletions src/libstd/sys/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,3 +515,7 @@ pub fn exit(code: i32) -> ! {
pub fn getpid() -> u32 {
unsafe { libc::getpid() as u32 }
}

pub fn getppid() -> u32 {
unsafe { libc::getppid() as u32 }
}

0 comments on commit fe2ec73

Please sign in to comment.