summaryrefslogtreecommitdiff
path: root/src/pidfd_getfd.c
blob: dc263e27b469328cda7e188a3ef5239f3424a4de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
 * pidfd_getfd() syscall decoder.
 *
 * Copyright (c) 2020 The strace developers.
 * All rights reserved.
 *
 * SPDX-License-Identifier: LGPL-2.1-or-later
 */

#include "defs.h"
#include "number_set.h"

SYS_FUNC(pidfd_getfd)
{
	int pidfd = (int) tcp->u_arg[0];
	int targetfd = (int) tcp->u_arg[1];
	unsigned int flags = (unsigned int) tcp->u_arg[2];

	printfd(tcp, pidfd);
	tprints(", ");

	pid_t target_pid = pidfd_get_pid(tcp->pid, pidfd);
	if (target_pid > 0)
		printfd_pid(tcp, target_pid, targetfd);
	else
		tprintf("%d", targetfd);

	tprintf(", %#x", flags);

	return RVAL_DECODED | RVAL_FD;
}