If an application does a fork() and the child dies with an abort() (due to failing an assert()), will the parent process receive a SI开发者_如何学GoGCHLD?
If it's relevant this is on Debian 4 (gcc version 4.1.2).
If you want to check the same,write a sample code which forks a child and the child calls abort() (To raise the sigabrt signal). Check its output on strace.(strace executable)
For the following code:
 #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;
    }
I get this output:
     --- SIGCHLD (Child exited) @ 0 (0) ---
     gettid()                                = 4226
     tgkill(4226, 4226, SIGABRT)             = 0
     --- SIGABRT (Aborted) @ 0 (0) ---
     +++ killed by SIGABRT +++
So the answer is yes, at least on Ubuntu distro.
You would expect the parent to get a SIGCHLD any time a child terminates unless the child has separated itself off from the parent (IIRC using setsid() or setpgrp()). The main reason for a child doing this is if the child is starting a daemon process. See Here or Here for a deeper treatment of daemon processes.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论