views:

302

answers:

1

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.

+3  A: 

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.

paxdiablo
In the case of a shell using the process group (-g) option of renice also won't change currently running children as each command they execute goes into a different process group. But most programs will not change the process group of their children so it's a way to alter related processes.
George Phillips
Yeah, I figured by "renice on a parent", the questioner meant that specific PID. Obviously if you renice a process group or user, other processes may be affected.
paxdiablo