1
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
/* NetworkManager -- Network link manager
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with this program; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
* Copyright (C) 2012 Red Hat, Inc.
25
#include "nm-posix-signals.h"
28
/* Stores the original signal mask of NetworkManager process */
29
static sigset_t nm_original_signal_mask;
32
nm_save_original_signal_mask (sigset_t sig_mask)
34
nm_original_signal_mask = sig_mask;
38
nm_get_original_signal_mask (void)
40
return &nm_original_signal_mask;
45
* If a signal set is passed, those signals are unblocked. If user_data is NULL
46
* the process' signal mask is set to the saved original mask.
47
* Note: This function can be used in g_spawn_* as GSpawnChildSetupFunc()
51
nm_unblock_posix_signals (gpointer user_data)
53
sigset_t *user_sigset = (sigset_t *) user_data;
55
if (user_sigset != NULL) {
56
pthread_sigmask (SIG_UNBLOCK, user_sigset, NULL);
58
const sigset_t *orig_sig_mask = nm_get_original_signal_mask ();
59
pthread_sigmask (SIG_SETMASK, orig_sig_mask, NULL);