/* @(#) $Id: sig_op.c,v 1.5 2007/01/25 03:24:54 dcid Exp $ */ /* Copyright (C) 2004 Daniel B. Cid * All right reserved. * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public * License (version 2) as published by the FSF - Free Software * Foundation */ /* Functions to handle signal manipulation */ #ifndef WIN32 #include #include #include #include "sig_op.h" #include "file_op.h" #include "debug_op.h" #include "error_messages/error_messages.h" char *pidfile = NULL; void HandleSIG() { merror(SIGNAL_RECV, pidfile); DeletePID(pidfile); exit(1); } /* To avoid client-server communication problems */ void HandleSIGPIPE() { return; } void StartSIG(char *process_name) { /* Signal Manipulation go to HandleSIG() */ pidfile = process_name; signal(SIGHUP, SIG_IGN); signal(SIGINT, HandleSIG); signal(SIGQUIT, HandleSIG); signal(SIGTERM, HandleSIG); signal(SIGALRM, HandleSIG); signal(SIGPIPE, HandleSIGPIPE); } void StartSIG2(char *process_name, void (*func)(int)) { pidfile = process_name; signal(SIGHUP, SIG_IGN); signal(SIGINT, func); signal(SIGQUIT, func); signal(SIGTERM, func); signal(SIGALRM, func); signal(SIGPIPE, HandleSIGPIPE); } #endif /* EOF */