Can someone tell me what is the relationship between a specified nice
level and child processes?
For example, if I have a default nice
of 0
, and I start a script with nice 5
, which in turn starts some child processes (in this case about 20 in parallel), what is the nice of the child processes?
Best Answer
A child process inherits whatever
nice
value is held by the parent at the time that it is forked (in your example,5
).However, if the
nice
value of the parent process changes after forking the child processes, the child processes do not inherit the newnice
value.You can easily observe this with the monitoring tool
top
. If thenice
field (NI) is not shown by default, you can add it by pressingf
and choosingI
. This will add theNI
column to thetop
display.* I: NI = Nice value
Good information from
man 2 fork