提交 fe2ec734 编写于 作者: K kennytm 提交者: GitHub

Rollup merge of #46092 - sfackler:ppid, r=alexcrichton

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
......@@ -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
}
......@@ -191,3 +191,9 @@ fn into_raw_fd(self) -> RawFd {
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()
}
......@@ -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 }
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册