Fei Jie | 032a9a4 | 2016-03-17 17:30:45 +0800 | [diff] [blame] | 1 | #include "tests.h" |
| 2 | #include <sys/syscall.h> |
| 3 | |
| 4 | #if defined __NR_getpriority && defined __NR_setpriority |
| 5 | |
| 6 | # include <errno.h> |
| 7 | # include <stdio.h> |
| 8 | # include <sys/time.h> |
| 9 | # include <sys/resource.h> |
| 10 | # include <unistd.h> |
| 11 | |
| 12 | int |
| 13 | main(void) |
| 14 | { |
| 15 | const int pid = getpid(); |
| 16 | int rc = syscall(__NR_getpriority, PRIO_PROCESS, |
| 17 | (unsigned long) 0xffffffff00000000 | pid); |
| 18 | printf("getpriority(PRIO_PROCESS, %d) = %d\n", |
| 19 | pid, rc); |
| 20 | |
| 21 | if ((syscall(__NR_setpriority, PRIO_PROCESS, |
| 22 | (unsigned long) 0xffffffff00000000 | pid, |
| 23 | (unsigned long) 0xffffffff00000000)) == 0) { |
| 24 | printf("setpriority(PRIO_PROCESS, %d, 0) = 0\n", pid); |
| 25 | } else { |
| 26 | printf("setpriority(PRIO_PROCESS, %d, 0) = -1 %s (%m)\n", |
| 27 | pid, errno == EPERM ? "EPERM" : "EACCES"); |
| 28 | } |
| 29 | |
| 30 | puts("+++ exited with 0 +++"); |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | #else |
| 35 | |
| 36 | SKIP_MAIN_UNDEFINED("__NR_getpriority && _NR_setpriority") |
| 37 | |
| 38 | #endif |