Find the answer to your Linux question:
Results 1 to 4 of 4
Need to kill child process, if parent dies on SIGTERM, SIGINT or SIGSEGV. Read MAN, default action to these signals are abnormal termination. Created signal handler for these signals, send ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! legendbb's Avatar
    Join Date
    Mar 2007
    Location
    Canada
    Posts
    27

    Cool Is abort() enough to handle SIGTERM, SIGINT, SIGSEGV?


    Need to kill child process, if parent dies on SIGTERM, SIGINT or SIGSEGV.

    Read MAN, default action to these signals are abnormal termination.

    Created signal handler for these signals, send kill(child, SIGTERM) before abort().

    Works as expected, just not sure if doing it this way covers all the termination actions default dispositions of those signals do.

    I will need to restart the parent and repeat thousands time without reboot the system. Needs system stability.

    exit() vs abort() could make some difference,
    http://stackoverflow.com/questions/3...exit-and-abort

    Please comment,
    Last edited by legendbb; 09-23-2011 at 09:13 PM. Reason: added more thoughts

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,572
    When you kill a parent process, no matter how, its attached children will also be terminated - no special handling required. Under other circumstances, if a child dies and the parent doesn't execute a wait() then the child will be a zombie until the parent terminates.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Aug 2011
    Posts
    51
    If you did something like:
    xterm &
    and then kill the old xterm, the xterm that you just started which would the a child of the first xterm and it doesn't go away. What happens in that case is the PPID of the xterm becomes 1 (init). So, if the parent goes away the child doesn't exit.

  4. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,572
    Processes can detach themselves from their parent process. This is how daemons work. Other applications, such as xterm do the same. My previous comment was for the general case, where the child process does not run as a detached process.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •