~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/signal_handler.h

Merge Stewart's dead code removal

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
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
 
 
21
 
#ifndef DRIZZLED_SIGNAL_HANDLER_H
22
 
#define DRIZZLED_SIGNAL_HANDLER_H
23
 
 
24
 
#include <signal.h>
25
 
 
26
 
#include <cstdlib>
27
 
#include <cassert>
28
 
static bool volatile signal_thread_in_use= false;
29
 
extern "C" void drizzled_print_signal_warning(int sig);
30
 
extern "C" void drizzled_handle_segfault(int sig);
31
 
extern "C" void drizzled_end_thread_signal(int sig);
32
 
 
33
 
/*
34
 
  posix sigaction() based signal handler implementation
35
 
  On some systems, such as Mac OS X, sigset() results in flags
36
 
  such as SA_RESTART being set, and we want to make sure that no such
37
 
  flags are set.
38
 
*/
39
 
static inline void ignore_signal(int sig)
40
 
{
41
 
  /* Wow. There is a function sigaction which takes a pointer to a
42
 
    struct sigaction. */
43
 
  struct sigaction l_s;
44
 
  sigset_t l_set;
45
 
  sigemptyset(&l_set);
46
 
 
47
 
  assert(sig != 0);
48
 
  l_s.sa_handler= SIG_IGN;
49
 
  l_s.sa_mask= l_set;
50
 
  l_s.sa_flags= 0;
51
 
  int l_rc= sigaction(sig, &l_s, NULL);
52
 
  assert(l_rc == 0);
53
 
}
54
 
 
55
 
#endif /* DRIZZLED_SIGNAL_HANDLER_H */