On 2015-09-21 00:45, Massimo Manghi wrote:
Hi,
I'm working on an issue with mod_rivet, a content generator module that
embeds in Apache the interpreter of the Tcl scripting language. I won't
bother you with the details of the problem (but if anyone is interested
I'm ready to answer any questions) and let me put the question in short
form:
we need to give the module the ability to gently exit a child process,
something like the function clean_child_exit I found in both prefork.c
and worker.c MPMs that would do exactly what I need (delete the pChild
pool and trigger the associated cleanup functions) but I could not find
a public interface to it. Is there a public interface to achieve this
functionality? The function ap_mpm_safe_kill at first looked a good
candidate but I could not find documented if it's *the right way*
Have a look at apr_pool_cleanup_register.
I don't have pleasant memories with process pools. The problem is that
sometimes apache children take a long time to exit. When this happens
then the parent sends them signals in order to stop them, the signals
becoming progressively stronger (first sigterm, then sigkill if I
remember correctly). I do not remember the details, but I've been
getting segfaults at process exit, so I'm steering clear of process
pools since.
Have a look if the conf pool is what you'd need. It is cleaned up every
time the apache configuration is reloaded (the parent apache process
stays alive, the apache worker children are stopped and a new generation
of apache children is created). You can use the second callback of the
apr_pool_cleanup_register to clean up things in the children.
The difference between the conf pool and the process pool is the
following: the process pool is passed to the post_config and child_init
callbacks. The conf pool is not passed to child_init. So, in order to
initialise things in the conf_pool you'll need to set a callback in the
post_config hook. The post_config hook is executed as root in the parent
process, before it forks a new generation of children, every time the
apache configuration is reread (after each apache2ctl graceful). The
child_init hook is executed in the apache child every time the child
process is created and it executes without root privileges.
Sorin