document safety properties of the internal Process::new constructor · rust-lang/rust@0ce3619

File tree

1 file changed

lines changed

  • library/std/src/sys/pal/unix/process

1 file changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -877,6 +877,12 @@ pub struct Process {

877877
878878

impl Process {

879879

#[cfg(target_os = "linux")]

880+

/// # Safety

881+

///

882+

/// `pidfd` must either be -1 (representing no file descriptor) or a valid, exclusively owned file

883+

/// descriptor (See [I/O Safety]).

884+

///

885+

/// [I/O Safety]: crate::io#io-safety

880886

unsafe fn new(pid: pid_t, pidfd: pid_t) -> Self {

881887

use crate::os::unix::io::FromRawFd;

882888

use crate::sys_common::FromInner;