如果应用程序执行 afork()
并且子进程死于 a abort()
(由于失败 a assert()
),父进程会收到 aSIGCHLD
吗?
如果它是相关的,这是在 Debian 4(gcc 版本 4.1.2)上。
如果您想检查相同的内容,请编写一个分叉子的示例代码,然后子调用 abort() (以提高 sigabrt 信号)。在 strace 上检查其输出。(strace 可执行文件)
对于以下代码:
#include<stdio.h>
#include<unistd.h>
int main()
{
pid_t pid;
if(pid=fork()<0)
{
fprintf(stderr,"Error in forking");
}
else if(pid==0)
{
/*The child*/
abort();
}
else {
waitpid(pid,(int *)0,0);
}
return 0;
}
我得到这个输出:
--- SIGCHLD (Child exited) @ 0 (0) ---
gettid() = 4226
tgkill(4226, 4226, SIGABRT) = 0
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT +++
所以答案是肯定的,至少在 Ubuntu 发行版上是这样。