Um processo filho herda o valor nice
retido pelo pai no momento em que é bifurcado (no seu exemplo, 5
).
No entanto, se o valor nice
do processo pai for alterado após a bifurcação dos processos filhos, os processos filhos não herdarão o novo valor nice
.
Você pode facilmente observar isso com a ferramenta de monitoramento top
. Se o campo nice
(NI) não for exibido por padrão, você poderá adicioná-lo pressionando f
e escolhendo I
. Isso adicionará a coluna NI
à exibição top
.
* I: NI = Nice value
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1937 root 20 0 206m 66m 45m S 6.2 1.7 11:03.67 X
Boas informações de man 2 fork
fork() creates a new process by duplicating the calling process. The new process, referred to as the child, is an exact duplicate of the calling process, referred to as the parent, except for the following points:
- The child has its own unique process ID, and this PID does not match the ID of any existing process group (setpgid(2)).
- The child's parent process ID is the same as the parent's process ID.
- The child does not inherit its parent's memory locks (mlock(2), mlockall(2)).
- Process resource utilizations (getrusage(2)) and CPU time counters (times(2)) are reset to zero in the child.
- The child's set of pending signals is initially empty (sigpending(2)).
- The child does not inherit semaphore adjustments from its parent (semop(2)).
- The child does not inherit record locks from its parent (fcntl(2)).
- The child does not inherit timers from its parent (setitimer(2), alarm(2), timer_create(2)).
- The child does not inherit outstanding asynchronous I/O operations from its parent (aio_read(3), aio_write(3)), nor does it inherit any asynchronous I/O contexts from its parent (see io_setup(2)).