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

Jakub Hrozek jhrozek at redhat.com
Thu Aug 6 15:13:05 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkp68vYACgkQHsardTLnvCUV8wCg5o0BtIGLkiobcBosAxWZhemW
pE4AniOJuvKKzt2ErY4OJkoQkRqPaSpX
=+x7i
-----END PGP SIGNATURE-----




More information about the Freeipa-devel mailing list