1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include "common/BackTrace.h"
16 #include "common/perf_counters.h"
17 #include "global/pidfile.h"
18 #include "common/debug.h"
19 #include "common/signal.h"
20 #include "common/config.h"
26 #include <sys/types.h>
28 std::string signal_mask_to_str()
31 if (pthread_sigmask(SIG_SETMASK, NULL, &old_sigset)) {
32 return "(pthread_signmask failed)";
36 oss << "show_signal_mask: { ";
38 for (int signum = 0; signum < NSIG; ++signum) {
39 if (sigismember(&old_sigset, signum) == 1) {
48 /* Block the signals in 'siglist'. If siglist == NULL, block all signals. */
49 void block_signals(const int *siglist, sigset_t *old_sigset)
59 sigaddset(&sigset, siglist[i]);
63 int ret = pthread_sigmask(SIG_BLOCK, &sigset, old_sigset);
67 void restore_sigset(const sigset_t *old_sigset)
69 int ret = pthread_sigmask(SIG_SETMASK, old_sigset, NULL);
73 void unblock_all_signals(sigset_t *old_sigset)
77 sigdelset(&sigset, SIGKILL);
78 int ret = pthread_sigmask(SIG_UNBLOCK, &sigset, old_sigset);