blob: 11cb7edd034928347a2987e36b65a93c0b8437e1 (
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
|
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/resource.h>
#include <unistd.h>
int main() {
errno = 0;
int original_priority = getpriority(PRIO_PROCESS, getpid());
assert(original_priority != -1 || !errno);
int ret = setpriority(PRIO_PROCESS, getpid(), original_priority + 1);
if(ret) {
fprintf(stderr, "%s", strerror(errno));
exit(1);
}
errno = 0;
int new_priority = getpriority(PRIO_PROCESS, getpid());
assert(new_priority != -1 || !errno);
assert(new_priority == original_priority + 1);
}
|