1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
5 * Copyright (C) 2001-2010, Eduardo Silva P. <edsiper@gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Library General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 #include <arpa/inet.h>
27 #include <netinet/in.h>
29 #include <sys/types.h>
38 /* (by Daniel R. Ome) */
39 void mk_signal_handler(int signo
)
44 /* Fixme: not yet implemented */
45 printf("%s => Monkey reconfiguration \n", log_current_time
.data
);
49 mk_utils_remove_pid();
50 printf("\n\n%s => Interrupt from keyboard\n\n",
51 log_current_time
.data
);
54 printf("%s => Hangup\n", log_current_time
.data
);
65 printf("%s => Invalid memory reference\n", log_current_time
.data
);
69 printf("%s => Termination signal\n", log_current_time
.data
);
79 signal(SIGHUP
, (void *) mk_signal_handler
);
80 signal(SIGINT
, (void *) mk_signal_handler
);
81 signal(SIGPIPE
, (void *) mk_signal_handler
);
82 signal(SIGBUS
, (void *) mk_signal_handler
);
83 signal(SIGSEGV
, (void *) mk_signal_handler
);
84 signal(SIGTERM
, (void *) mk_signal_handler
);
85 signal(SIGUSR2
, (void *) mk_signal_handler
);
90 signal(SIGHUP
, (void *) SIG_DFL
);
91 signal(SIGINT
, (void *) SIG_DFL
);
92 signal(SIGPIPE
, (void *) SIG_DFL
);
93 signal(SIGBUS
, (void *) SIG_DFL
);
94 signal(SIGSEGV
, (void *) SIG_DFL
);
95 signal(SIGTERM
, (void *) SIG_DFL
);
96 signal(SIGUSR2
, (void *) SIG_DFL
);
99 void mk_signal_thread_sigpipe_safe()
104 sigaddset(&set
, SIGPIPE
);
105 pthread_sigmask(SIG_BLOCK
, &set
, &old
);