~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/signal_handler.h

  • Committer: Daniel Nichter
  • Date: 2011-10-23 16:01:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2448.
  • Revision ID: daniel@percona.com-20111023160137-7ac3blgz8z4tf8za
Add Administration Getting Started and Logging.  Capitalize SQL clause keywords.

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
#pragma once
 
22
 
 
23
#include <signal.h>
 
24
 
 
25
#include <cstdlib>
 
26
#include <cassert>
 
27
static bool volatile signal_thread_in_use= false;
 
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
*/
 
38
static inline void ignore_signal(int sig)
 
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;
 
44
  sigemptyset(&l_set);
 
45
 
 
46
  assert(sig != 0);
 
47
  l_s.sa_handler= SIG_IGN;
 
48
  l_s.sa_mask= l_set;
 
49
  l_s.sa_flags= 0;
 
50
  int l_rc= sigaction(sig, &l_s, NULL);
 
51
  assert(l_rc == 0);
 
52
}
 
53