apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joachim Ziegler <zieg...@mpi-sb.mpg.de>
Subject Preferred portable way to talk to a server process
Date Tue, 03 Jun 2008 10:28:57 GMT
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

Mime
View raw message