pidfd_getfd - Online Linux Manual PageSection : 2
Updated : 2023-02-05
Source : Linux man-pages 6.03
NAMEpidfd_getfd − obtain a duplicate of another process's file descriptor
LIBRARYStandard C library (libc, −lc)
SYNOPSIS#include <sys/syscall.h> /* Definition of SYS_* constants */
#include <unistd.h>int syscall(SYS_pidfd_getfd, int pidfd, int targetfd,
unsigned int flags);Note: glibc provides no wrapper for pidfd_getfd(), necessitating the use of syscall(2).
DESCRIPTIONThe pidfd_getfd() system call allocates a new file descriptor in the calling process. This new file descriptor is a duplicate of an existing file descriptor, targetfd, in the process referred to by the PID file descriptor pidfd. The duplicate file descriptor refers to the same open file description (see open(2)) as the original file descriptor in the process referred to by pidfd. The two file descriptors thus share file status flags and file offset. Furthermore, operations on the underlying file object (for example, assigning an address to a socket object using bind(2)) can equally be performed via the duplicate file descriptor. The close-on-exec flag (FD_CLOEXEC; see fcntl(2)) is set on the file descriptor returned by pidfd_getfd(). The flags argument is reserved for future use. Currently, it must be specified as 0. Permission to duplicate another process's file descriptor is governed by a ptrace access mode PTRACE_MODE_ATTACH_REALCREDS check (see ptrace(2)).
RETURN VALUEOn success, pidfd_getfd() returns a file descriptor (a nonnegative integer). On error, −1 is returned and errno is set to indicate the error.
ERRORSEBADF pidfd is not a valid PID file descriptor. EBADF targetfd is not an open file descriptor in the process referred to by pidfd. EINVAL flags is not 0. EMFILE The per-process limit on the number of open file descriptors has been reached (see the description of RLIMIT_NOFILE in getrlimit(2)). ENFILE The system-wide limit on the total number of open files has been reached. EPERM The calling process did not have PTRACE_MODE_ATTACH_REALCREDS permissions (see ptrace(2)) over the process referred to by pidfd. ESRCH The process referred to by pidfd does not exist (i.e., it has terminated and been waited on).
VERSIONSpidfd_getfd() first appeared in Linux 5.6.
STANDARDSpidfd_getfd() is Linux specific.
NOTESFor a description of PID file descriptors, see pidfd_open(2). The effect of pidfd_getfd() is similar to the use of SCM_RIGHTS messages described in unix(7), but differs in the following respects: • In order to pass a file descriptor using an SCM_RIGHTS message, the two processes must first establish a UNIX domain socket connection. • The use of SCM_RIGHTS requires cooperation on the part of the process whose file descriptor is being copied. By contrast, no such cooperation is necessary when using pidfd_getfd(). • The ability to use pidfd_getfd() is restricted by a PTRACE_MODE_ATTACH_REALCREDS ptrace access mode check.
SEE ALSOclone3(2), dup(2), kcmp(2), pidfd_open(2) 0
Johanes Gumabo
Data Size : 12,763 byte
man-pidfd_getfd.2Build : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 2 / 198,954
Visitor ID : :
Visitor IP : 18.118.166.45 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.