[Freeipa-devel] [PATCH] Make child processes exit when parent dies

Dmitri Pal dpal at redhat.com
Thu Aug 6 16:55:24 UTC 2009


Jakub Hrozek wrote:
> On 08/06/2009 11:53 AM, Simo Sorce wrote:
> >> How do we fork processes?
> >>> If we just fork and do not daemonize then children should just die
> >>> (system sends sigterm to children AFAIR) when the parent process
> exits.
> >>> At least that is what used to happen in old days on Solaris, HP
> and AIX.
> >>> If we fork and then make the process a new process group leader by
> using
> >>> setpgrp() then it terns into a service. It PPID becomes 1 (AFAIR -
> have
> >>> done it many years ago).
> >>> If our children are independent processes there is no good way other
> >>> than pass in the IP of the parent at the initialization and
> periodically
> >>> check if the process is still around and its start time is before
> child's.
> >>>
> >>> If the problem we are trying to solve is to exit back ends when
> monitor
> >>> dies we should either keep the children as members of the same
> group or
> >>> use the periodic check approach.
> > I have to say I am a bit surprised about this patch too.
> > Last time I put my hands on it we were using process groups exactly so
> > that when monitor is killed all other process die as well. In my
> > experience this works fine in master. In what cases do this fail ?
>
> > Simo.
>
>
> (We discussed this with Simo and Martin on IRC, I'm capturing the
> discussion also here)
>
> The way we use process groups works OK for normal situations - if, for
> example, the monitor gets SIGTERM from an initscript, it passes it on to
> its child processes in a signal handler. The patch tries to solve a
> situation where monitor crashes, either with something like SIGSEGV or
> the admin kills it with SIGKILL.
>
> We could catch most signals the way we do catch SIGTERM and relay them
> to children. This still wouldn't cover the SIGKILL case where the admin
> shoots down monitor. This is cross-platform which is of course huge
> advantage.
>
> But in my opinion, we should still use prctl() where available, because
> it is much cleaner solution -- you don't have to explicitly enumerate
> all the signals to handle and you can also cover the SIGKILL case.
>
>     Jakub
>
May be I have false memories but I was under the impression that OS
takes care of the orphan children and terminates them automatically by
sending them a signal
if it detects that parent process goes away. Am I wrong?
-- 
Thank you,
Dmitri Pal

Engineering Manager IPA project,
Red Hat Inc.


-------------------------------
Looking to carve out IT costs?
www.redhat.com/carveoutcosts/




More information about the Freeipa-devel mailing list