The purpose of the wait() in parent c

前端 未结 3 1710
北恋
北恋 2021-01-27 14:40

I am new to processes in linux and c. I am using this straightforward example:

#include 
#include 
#include 

int         


        
3条回答
  •  忘了有多久
    2021-01-27 15:29

    Wait is for listening to state changes and obtaining information about the child. A state change is child termination, stopping or resuming by a signal. Wait allows the system to release the resources associated with the child. If a wait is not performed, then the terminated child remains in a "zombie" state.

    The kernel maintains a minimal set of information about the zombie process (PID, termination status, resource usage information) in order to allow the parent to later perform a wait to obtain information about the child. As long as a zombie is not removed from the system via a wait, it will consume a slot in the kernel process table, and if this table fills, it will not be possible to create further processes. If a parent process terminates, then its "zombie" children (if any) are adopted by init(1), which automatically performs a wait to remove the zombies.

提交回复
热议问题