1 /*
2 * Check decoding of getpriority and setpriority syscalls.
3 *
4 * Copyright (c) 2016-2021 The strace developers.
5 * All rights reserved.
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10 #include "tests.h"
11 #include "scno.h"
12 #include "pidns.h"
13
14 #include <stdio.h>
15 #include <sys/resource.h>
16 #include <unistd.h>
17
18 int
19 main(void)
20 {
21 PIDNS_TEST_INIT;
22
23 const int pid = getpid();
24 const int pgid = getpgid(0);
25
26 long rc = syscall(__NR_getpriority, PRIO_PROCESS,
27 F8ILL_KULONG_MASK | pid);
28 pidns_print_leader();
29 printf("getpriority(PRIO_PROCESS, %d%s) = %ld\n",
30 pid, pidns_pid2str(PT_TGID), rc);
31
32 rc = syscall(__NR_setpriority, PRIO_PROCESS,
33 F8ILL_KULONG_MASK | pid, F8ILL_KULONG_MASK);
34 pidns_print_leader();
35 printf("setpriority(PRIO_PROCESS, %d%s, 0) = %s\n",
36 pid, pidns_pid2str(PT_TGID), sprintrc(rc));
37
38 rc = syscall(__NR_getpriority, PRIO_PGRP,
39 F8ILL_KULONG_MASK | pgid);
40 pidns_print_leader();
41 printf("getpriority(PRIO_PGRP, %d%s) = %ld\n",
42 pgid, pidns_pid2str(PT_PGID), rc);
43
44 pidns_print_leader();
45 puts("+++ exited with 0 +++");
46 return 0;
47 }