You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rivet-dev@tcl.apache.org by Massimo Manghi <ma...@unipr.it> on 2011/01/19 10:14:58 UTC

Tcl interpreters and signal handlers

Hi

a help request from you, Tcl gurus. If you're unwilling to read the whole
message my question can be summarized as "can Tcl interpreters
install (POSIX?) signal handlers on their own? Have these handlers
to be explicitly removed from signal handling before the interpreter
is deleted?"

Here is how the question arose.

As a fun project I added a ServerInitScript configuration
parameter in a  working copy checked out from trunk.

This configuration script is meant to run only once, after configuration
record is built and before children are forked.
The purpose is to give mod_rivet a hook to scripts that have to create
ipc methods references (PHP has something like this IIRC).

The following is the code in Rivet_InitHandler (purged from the error 
checking
and logging lines; after all no errors were logged in real tests!)

    if (rsc->rivet_server_init_script != NULL) {
        Tcl_Interp* interp = Tcl_CreateInterp();
        Tcl_Init(interp)
        Tcl_EvalObjEx(interp, rsc->rivet_server_init_script, 0)
         Tcl_DeleteInterp(interp);
    }


The code works (tried with a sort of 'hello world' script) but the 
server becomes
unresponsive when shutting it down. Apache prints in the error log lines 
like this

[Wed Jan 19 00:40:08 2011] [error] child process 10440 still did not 
exit, sending a SIGKILL

for every child process to be shut down, suggesting that some signal handler
is catching the SIGTERM, hiding it from its default handler. Removing 
from the
configuration the script that is assigned to 
rsc->rivet_server_init_script enables
Apache to shutdown gently and switfly, suggesting the problem is with the
interpreter. The script was

puts stderr "server init script runs at [clock format [clock seconds]]"

and prints in the error log as expected

hints?

--  Massimo