Skip to main content

pidfd_getfd

Function pidfd_getfd 

Source
pub unsafe fn pidfd_getfd(pidfd: c_int, targetfd: c_int, flags: c_uint) -> c_int
Expand description

Takes the file description referred to by targetfd within pidfd and creates a duplicate of it within this process.

This is the raw syscall. For a somewhat more convenient wrapper, see get_file_from_pidfd.

If this syscall is successful, it returns the new file descriptor. Otherwise, it returns -1 and sets errno. For more information, see the man page for pidfd_getfd(2).

ยงSafety

The caller is responsible for upholding any requirements detailed in the aforementioned man page. At the time of writing (2021-08-05, kernel version 5.10.28), flags must be set to 0.