blob: 6d0e809bde9551d68346e6f42c9a9b9dd47796ba [file] [log] [blame]
Josh Gao3de19152021-02-22 18:09:48 -08001/*
2 * Copyright (C) 2021 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28#pragma once
29
30/**
31 * @file sys/pidfd.h
32 * @brief File descriptors representing processes.
33 */
34
35#include <sys/cdefs.h>
36#include <sys/types.h>
37
38#include <bits/signal_types.h>
39
40__BEGIN_DECLS
41
42/**
43 * [pidfd_open(2)](https://man7.org/linux/man-pages/man2/pidfd_open.2.html)
44 * opens a file descriptor that refers to a process. This file descriptor will
45 * have the close-on-exec flag set by default.
46 *
47 * Returns a new file descriptor on success and returns -1 and sets `errno` on
48 * failure.
49 *
50 * Available since API level 31.
51 */
52int pidfd_open(pid_t __pid, unsigned int __flags) __INTRODUCED_IN(31);
53
54/**
55 * [pidfd_getfd(2)](https://man7.org/linux/man-pages/man2/pidfd_open.2.html)
56 * dups a file descriptor from another process. This file descriptor will have
57 * the close-on-exec flag set by default.
58 *
59 * Returns a new file descriptor on success and returns -1 and sets `errno` on
60 * failure.
61 *
62 * Available since API level 31.
63 */
64int pidfd_getfd(int __pidfd, int __targetfd, unsigned int __flags) __INTRODUCED_IN(31);
65
66/**
67 * [pidfd_send_signal(2)](https://man7.org/linux/man-pages/man2/pidfd_send_signal.2.html)
68 * sends a signal to another process.
69 *
70 * Returns 0 on success and returns -1 and sets `errno` on failure.
71 *
72 * Available since API level 31.
73 */
74int pidfd_send_signal(int __pidfd, int __sig, siginfo_t *__info, unsigned int __flags) __INTRODUCED_IN(31);
75
76__END_DECLS