As I understand every user in linux can change the every process's priority by using nice and renice commands. Also I know that the all users just can increase the priority of processes and the only user that can decrease this priority is ROOT.
When I test this in Terminal environment using these commands everything was OK. Mean's that when I want to decrease the priority of process the system issues the "permission denied" text message.
As I know too by default all processes runs with priority 0
.So when I want to set an process's priority by a negative number, the system must issues an error text. When I run this C language program:
#include<stdio.h>
#include<unistd.h>
void main()
{
int n=10,r;
r=nice(n);
while(1)
printf("Test);
}
I expected that the system shows an error But program runs with no problem! Although the program runs by a typical user permission.
I want to know why when I want to decrease the process's priority using renice command according to what was expected the system shows error, but when I want to decrease process's priority by using nice()
function the programs doesn't issues any error?
Is this sentence All users just can increase the priority of process and the only user that can decrease this priority is ROOT.
correct?
nice()
function in my program, I can decrease the process's priority(Although I have my typical user!)?