1300.5.22
by Monty Taylor
Moved and reworked a wrapper around sigset - which we shouldn't be using |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008 Sun Microsystems, Inc.
|
1300.5.22
by Monty Taylor
Moved and reworked a wrapper around sigset - which we shouldn't be using |
5 |
* Copyright (C) 2010 Monty Taylor
|
6 |
*
|
|
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; version 2 of the License.
|
|
10 |
*
|
|
11 |
* This program is distributed in the hope that it will be useful,
|
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License
|
|
17 |
* along with this program; if not, write to the Free Software
|
|
18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
19 |
*/
|
|
20 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
21 |
#pragma once
|
1300.5.22
by Monty Taylor
Moved and reworked a wrapper around sigset - which we shouldn't be using |
22 |
|
23 |
#include <signal.h> |
|
24 |
||
25 |
#include <cstdlib> |
|
26 |
#include <cassert> |
|
1733.3.1
by LinuxJedi
Make exit happen in main thread rather than signal handler thread thus avoiding a segfault due to a double kill of the signal handler thread |
27 |
static bool volatile signal_thread_in_use= false; |
1300.5.22
by Monty Taylor
Moved and reworked a wrapper around sigset - which we shouldn't be using |
28 |
extern "C" void drizzled_print_signal_warning(int sig); |
29 |
extern "C" void drizzled_handle_segfault(int sig); |
|
30 |
extern "C" void drizzled_end_thread_signal(int sig); |
|
31 |
||
32 |
/*
|
|
33 |
posix sigaction() based signal handler implementation
|
|
34 |
On some systems, such as Mac OS X, sigset() results in flags
|
|
35 |
such as SA_RESTART being set, and we want to make sure that no such
|
|
36 |
flags are set.
|
|
37 |
*/
|
|
1300.5.23
by Monty Taylor
Merged in revs removing depend on the plugin tree. |
38 |
static inline void ignore_signal(int sig) |
1300.5.22
by Monty Taylor
Moved and reworked a wrapper around sigset - which we shouldn't be using |
39 |
{
|
40 |
/* Wow. There is a function sigaction which takes a pointer to a
|
|
41 |
struct sigaction. */
|
|
42 |
struct sigaction l_s; |
|
43 |
sigset_t l_set; |
|
1300.5.23
by Monty Taylor
Merged in revs removing depend on the plugin tree. |
44 |
sigemptyset(&l_set); |
1300.5.22
by Monty Taylor
Moved and reworked a wrapper around sigset - which we shouldn't be using |
45 |
|
46 |
assert(sig != 0); |
|
1300.5.23
by Monty Taylor
Merged in revs removing depend on the plugin tree. |
47 |
l_s.sa_handler= SIG_IGN; |
1300.5.22
by Monty Taylor
Moved and reworked a wrapper around sigset - which we shouldn't be using |
48 |
l_s.sa_mask= l_set; |
49 |
l_s.sa_flags= 0; |
|
1300.5.23
by Monty Taylor
Merged in revs removing depend on the plugin tree. |
50 |
int l_rc= sigaction(sig, &l_s, NULL); |
1300.5.22
by Monty Taylor
Moved and reworked a wrapper around sigset - which we shouldn't be using |
51 |
assert(l_rc == 0); |
52 |
}
|
|
53 |