1/* Wrapper for file descriptors that refers to a process functions.
2 Copyright (C) 2022-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#ifndef _PIDFD_H
20
21#include <fcntl.h>
22#include <bits/types/siginfo_t.h>
23
24#define PIDFD_NONBLOCK O_NONBLOCK
25
26/* Returns a file descriptor that refers to the process PID. The
27 close-on-exec is set on the file descriptor.
28
29 The FLAGS argument is reserved for future use, it must be specified
30 as 0. */
31extern int pidfd_open (__pid_t __pid, unsigned int __flags) __THROW;
32
33/* Duplicates an existing file descriptor TARGETFD in the process referred
34 by the PIDFD file descriptor PIDFD.
35
36 The FLAGS argument is reserved for future use, it must be specified
37 as 0. */
38extern int pidfd_getfd (int __pidfd, int __targetfd,
39 unsigned int __flags) __THROW;
40
41/* Sends the signal SIG to the target process referred by the PIDFD. If
42 INFO points to a siginfo_t buffer, it will be populated.
43
44 The FLAGS argument is reserved for future use, it must be specified
45 as 0. */
46extern int pidfd_send_signal (int __pidfd, int __sig, siginfo_t *__info,
47 unsigned int __flags) __THROW;
48
49/* Query the process ID (PID) from process descriptor FD. Return the PID
50 or -1 in case of an error. */
51extern pid_t pidfd_getpid (int __fd) __THROW;
52
53#endif /* _PIDFD_H */
54

source code of glibc/sysdeps/unix/sysv/linux/sys/pidfd.h