TreeviewCopyright © aleen42 all right reserved, powered by aleen42
Kill Processes Back
exit()to kill processes
- if the process is the group leader of a processes group, then send SIGHUP to all processes in this group
- close all socket opened by this process
- if there are children process, then set their parent as init process
- send SIGCHLD to its parent
- Zombie(僵屍) Process will be created when SIGCHLD is not handled by its parent
- Zombies will occupy a Process Table Entry(進程表項) in the system
- ways to kill Zomebie Process
- ignore SIGCHLD using SIG_IGN, and system will clear their Process Table Entries.
waitpid()to wait for killing child processes.
waitpid()to handler more than one killing child process by setting WNOHANG, prevented to be blocked, rather than
fork()twice so that child process will be controled by init process.
pid_t waitpid(pid_t pid, int* status, int option)
- pid: 進程id
- >0: 只等待進程號為pid的子進程退出
- -1: 等待任何子進程退出
- option: 選項
- WHONANG: 無子進程退出時不阻塞
- status: 存儲狀態信息
- 0: 設置WHONANG且無子進程退出
- -1: failure
- errno: error code