You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Joachim Ziegler <zi...@mpi-sb.mpg.de> on 2008/06/03 12:28:57 UTC

Preferred portable way to talk to a server process

Hello,

what's the preferred, portable way in APR to talk to a server process
for saying such things as "do a clean shutdown", "reload your config
file", "re-index your database" and so on?

I've read in the archives of the mailing list that (Unix-)signals are
"highly non-portable". Which interprocess communication concept should I
use to get the same code running under Unix and Windows?

Nevertheless I have written a little demo server that uses

 apr_signal( SIGTERM, activateCleanShutdown );

to catch SIGTERM and then shut down.

This does not fully work under Windows: I have to catch SIGINT instead
of SIGTERM. Pressing CTRL-C once creates and catches a signal with the
number 2, so that I can set a variable "doShutDown" to true.
Unfortunately, apr_socket_accept() still blocks, and second CTRL-C stops
the program, so I can never test the variable doShutDown.

What is the preferred way to do this?

BTW, I had to change the following Unix lines

 apr_sigfunc_t activateCleanShutdown; /* declare the handler  */
 apr_signal( SIGTERM, activateCleanShutdown );

under Windows to

void activateCleanShutdown(int);
apr_signal( SIGINT, activateCleanShutdown );

The Visual Studio compiler claims that "apr_sigfunc_t" be an undeclared
identifier.


Greetings,
Joachim