Linux信号详解:signal与sigaction函数
Posted 白马负金羁
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux信号详解:signal与sigaction函数相关的知识,希望对你有一定的参考价值。
在此前的系列文章中,我们已经介绍了signal函数的基本用法,本文将通过若干例子帮助读者增进对于它的了解。
一、僵尸进程(Zombie Process)与信号屏蔽(忽略)
僵尸进程是当子进程比父进程先结束,而父进程又没有回收子进程,释放子进程占用的资源,此时子进程将成为一个僵尸进程。如果父进程先退出 ,子进程被init接管,子进程退出后init会回收其占用的相关资源。
Once a child process “exits”, it enters the zombie state process.
If a parent process exits, its zombie child processes become children of the init (pid = 1) process, which periodically reaps zombies
Zombie processes occupy precious kernel resources (e.g., PCB), so you want to reclaim them as soon as possible.
但Linux中为什么要设计zombie process这种机制呢?
这种机制allow the parent process to read its child\'s exit status。
The zombie process is not gone (or cleaned up) unless
- Its parent calls wait() to retrieve the exit state;
- its parent has explicitly expressed no interest in the exit state (the parent expl
以上是关于Linux信号详解:signal与sigaction函数的主要内容,如果未能解决你的问题,请参考以下文章