1 /*
2 * pidfd_getfd() syscall decoder.
3 *
4 * Copyright (c) 2020-2021 The strace developers.
5 * All rights reserved.
6 *
7 * SPDX-License-Identifier: LGPL-2.1-or-later
8 */
9
10 #include "defs.h"
11 #include "number_set.h"
12
13 SYS_FUNC(pidfd_getfd)
14 {
15 int pidfd = (int) tcp->u_arg[0];
16 int targetfd = (int) tcp->u_arg[1];
17 unsigned int flags = (unsigned int) tcp->u_arg[2];
18
19 /* pidfd */
20 printfd(tcp, pidfd);
21 tprint_arg_next();
22
23 /* targetfd */
24 pid_t target_pid = pidfd_get_pid(tcp->pid, pidfd);
25 if (target_pid > 0)
26 printfd_pid(tcp, target_pid, targetfd);
27 else
28 PRINT_VAL_D(targetfd);
29 tprint_arg_next();
30
31 /* flags */
32 PRINT_VAL_X(flags);
33
34 return RVAL_DECODED | RVAL_FD;
35 }