Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does renice on a parent renice the child?

Tags:

shell

nice

renice

I know if I nice a shell script (ie: before it runs) all processes that start from the shell script will also be niced.

What if I start a shell script and the renice it, do all the child processes become reniced as well?

Looked in the renice man pages and there are no mention of child processes.

like image 982
hhafez Avatar asked Jun 30 '09 04:06

hhafez


1 Answers

Children inherit the current priority of a process when they're created. That means, if you renice the parent and start a child, it will have the modified priority.

Children that are already running when you renice are not affected.

The clue is in the fork() man pages (starting a child is a fork/exec operation):

fork() creates a child process that differs from the parent process only in its PID and PPID, and in the fact that resource utilizations are set to 0.

like image 70
paxdiablo Avatar answered Oct 21 '22 18:10

paxdiablo