1 /*
2 * breaksig.c -- SIGBREAK, etc. signal handlers
3 *
4 * breaksig.c is a part of binkd project
5 *
6 * Copyright (C) 1996 Dima Maloff, 5047/13
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. See COPYING.
12 */
13
14 /*
15 * $Id: breaksig.c,v 2.5 2003/10/29 21:08:38 gul Exp $
16 *
17 * $Log: breaksig.c,v $
18 * Revision 2.5 2003/10/29 21:08:38 gul
19 * Change include-files structure, relax dependences
20 *
21 * Revision 2.4 2003/08/26 21:01:09 gul
22 * Fix compilation under unix
23 *
24 * Revision 2.3 2003/08/26 16:06:26 stream
25 * Reload configuration on-the fly.
26 *
27 * Warning! Lot of code can be broken (Perl for sure).
28 * Compilation checked only under OS/2-Watcom and NT-MSVC (without Perl)
29 *
30 * Revision 2.2 2003/03/10 10:39:23 gul
31 * New include file common.h
32 *
33 * Revision 2.1 2003/02/28 20:39:08 gul
34 * Code cleanup:
35 * change "()" to "(void)" in function declarations;
36 * change C++-style comments to C-style
37 *
38 * Revision 2.0 2001/01/10 12:12:37 gul
39 * Binkd is under CVS again
40 *
41 * Revision 1.3 1997/10/23 04:18:08 mff
42 * exitfunc() moved to exitproc.c, minor changes
43 *
44 * Revision 1.2 1997/03/09 07:17:16 mff
45 * Support for pid_file
46 *
47 * Revision 1.1 1996/12/14 07:02:20 mff
48 * Initial revision
49 *
50 */
51
52 #include <stdlib.h>
53 #include <signal.h>
54 #include <stdio.h>
55 #include "sys.h"
56 #include "common.h"
57 #include "tools.h"
58
exitsig(int arg)59 static void exitsig (int arg)
60 {
61 /* Log (0, ...) will call exit(), exit() will call exitlist */
62 #ifdef HAVE_FORK
63 if (pidcmgr)
64 Log (0, "got signal #%i. Killing %i and quitting...", arg, (int) pidcmgr);
65 else
66 #endif
67 Log (0, "got signal #%i.", arg);
68 }
69
70 /* Set up break handler, set up exit list if needed */
set_break_handlers(void)71 int set_break_handlers (void)
72 {
73 atexit (exitfunc);
74
75 #ifdef SIGBREAK
76 signal (SIGBREAK, exitsig);
77 #endif
78 #ifdef SIGHUP
79 signal (SIGHUP, SIG_IGN);
80 #endif
81 #ifdef SIGINT
82 signal (SIGINT, exitsig);
83 #endif
84 #ifdef SIGTERM
85 signal (SIGTERM, exitsig);
86 #endif
87 return 1;
88 }
89