1 /* Copyright (C) 2009 Trend Micro Inc.
4 * This program is a free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License (version 2) as published by the FSF - Free Software
10 /* Functions to handle signal manipulation */
22 #include "error_messages/error_messages.h"
24 static const char *pidfile = NULL;
27 void HandleSIG(int sig)
29 merror(SIGNAL_RECV, pidfile, sig, strsignal(sig));
37 /* To avoid client-server communication problems */
38 void HandleSIGPIPE(__attribute__((unused)) int sig)
43 void StartSIG(const char *process_name)
45 pidfile = process_name;
47 signal(SIGHUP, SIG_IGN);
48 signal(SIGINT, HandleSIG);
49 signal(SIGQUIT, HandleSIG);
50 signal(SIGTERM, HandleSIG);
51 signal(SIGALRM, HandleSIG);
52 signal(SIGPIPE, HandleSIGPIPE);
55 void StartSIG2(const char *process_name, void (*func)(int))
57 pidfile = process_name;
59 signal(SIGHUP, SIG_IGN);
61 signal(SIGQUIT, func);
62 signal(SIGTERM, func);
63 signal(SIGALRM, func);
64 signal(SIGPIPE, HandleSIGPIPE);