shellnicerenice

Does renice on a parent renice the child?


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.


Solution

  • 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.