1 /* Copyright (C) 2006  Britton Leo Kerin, see copyright.  */
2 
3 /* Handler for SIGTERM.  This function may eventually be generalized
4    to handle other signals which cause the program to shutdown as well
5    in the same way (by setting a flag) at which time its name will
6    need to be changed.  */
7 
8 #include <signal.h>
9 #include <stdio.h>
10 
11 /* This prototype isn't in rawrec.h, since this somewhat awkward
12    method of dealing with these signals will go away someday.  */
13 void shutdown_signal_handler(int signum);
14 
15 /* Flag to indicate to the outside world that we caught a shutdown
16    signal, since we can't POSIXly do pthread calls from the handler
17    itself.  It true, this gets set to the value of the signal we
18    got.  */
19 int got_watched_for_shutdown_signal = 0;
20 
21 /* This handler is only installed on signals for which we want to do
22    clean managed shutdown.  */
shutdown_signal_handler(int signum)23 void shutdown_signal_handler(int signum)
24 {
25   got_watched_for_shutdown_signal = signum;
26 }
27