#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>

int main()
{
    int width, pid, priority, res;

    width = 15;
    pid = getpid();
    printf("%*s id: %d\n", width, "Process", pid);
    printf("%*s id: %d\n", width, "Parent process", getppid());
    printf("%*s id: %d\n", width, "User", getuid());
    printf("%*s id: %d\n", width, "Effective User", geteuid());
    printf("%*s id: %d\n", width, "Group", getgid());
    printf("%*s id: %d\n", width, "Effective Group", getegid());
    printf("%*s id: %d\n", width, "Session", getsid(pid));
    printf("%*s id: %d\n", width, "Process group", getpgid(pid));

    priority = getpriority(PRIO_PROCESS, pid);
    printf("%d\n", priority);
    getchar();

    res = setpriority(PRIO_PROCESS, pid, 5);
    if (res == -1) {
        perror("setpriority");
        exit(1);
    }
    priority = getpriority(PRIO_PROCESS, pid);
    printf("%d\n", priority);
    getchar();

    nice(5);

    priority = getpriority(PRIO_PROCESS, pid);
    printf("%d\n", priority);
    getchar();

    return 0;
}
