mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-08 20:00:23 +01:00
core: use GUnixSignalWatchSource to simplify signal handling
Replace the pthread_sigwait()-based signal handling with
g_unix_signal_add()-based handling, and get rid of all the
now-unnecessary calls to nm_unblock_posix_signals() when spawning
subprocesses.
As a bonus, this also fixes the "^C in gdb kills NM too" bug.
(cherry picked from commit c5b3e93792)
This commit is contained in:
parent
265b1d2b2a
commit
4213815d6b
20 changed files with 45 additions and 269 deletions
|
|
@ -326,8 +326,6 @@ nm_sources = \
|
|||
nm-manager.h \
|
||||
nm-policy.c \
|
||||
nm-policy.h \
|
||||
nm-posix-signals.c \
|
||||
nm-posix-signals.h \
|
||||
nm-properties-changed-signal.c \
|
||||
nm-properties-changed-signal.h \
|
||||
nm-rfkill-manager.c \
|
||||
|
|
@ -503,8 +501,6 @@ libnm_iface_helper_la_SOURCES = \
|
|||
nm-enum-types.h \
|
||||
nm-logging.c \
|
||||
nm-logging.h \
|
||||
nm-posix-signals.c \
|
||||
nm-posix-signals.h \
|
||||
NetworkManagerUtils.c \
|
||||
NetworkManagerUtils.h
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@
|
|||
#include "nm-setting-wireless.h"
|
||||
#include "nm-setting-wireless-security.h"
|
||||
#include "nm-auth-utils.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "gsystem-local-alloc.h"
|
||||
|
||||
|
|
@ -164,7 +163,7 @@ nm_spawn_process (const char *args, GError **error)
|
|||
g_return_val_if_fail (!error || !*error, -1);
|
||||
|
||||
if (g_shell_parse_argv (args, &num_args, &argv, &local)) {
|
||||
g_spawn_sync ("/", argv, NULL, 0, nm_unblock_posix_signals, NULL, NULL, NULL, &status, &local);
|
||||
g_spawn_sync ("/", argv, NULL, 0, NULL, NULL, NULL, NULL, &status, &local);
|
||||
g_strfreev (argv);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@
|
|||
#include "nm-enum-types.h"
|
||||
#include "nm-settings-connection.h"
|
||||
#include "nm-connection-provider.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "nm-auth-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-dispatcher.h"
|
||||
|
|
@ -2928,12 +2927,6 @@ aipd_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
*/
|
||||
pid_t pid = getpid ();
|
||||
setpgid (pid, pid);
|
||||
|
||||
/*
|
||||
* We blocked signals in main(). We need to restore original signal
|
||||
* mask for avahi-autoipd here so that it can receive signals.
|
||||
*/
|
||||
nm_unblock_posix_signals (NULL);
|
||||
}
|
||||
|
||||
/* default to installed helper, but can be modified for testing */
|
||||
|
|
@ -5341,8 +5334,7 @@ send_arps (NMDevice *self, const char *mode_arg)
|
|||
"arping: run %s", (tmp_str = g_strjoinv (" ", (char **) argv)));
|
||||
success = g_spawn_async (NULL, (char **) argv, NULL,
|
||||
G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
|
||||
nm_unblock_posix_signals,
|
||||
NULL, NULL, &error);
|
||||
NULL, NULL, NULL, &error);
|
||||
if (!success) {
|
||||
_LOGW (LOGD_DEVICE | LOGD_IP4,
|
||||
"arping: could not send ARP for local address %s: %s",
|
||||
|
|
@ -6483,7 +6475,7 @@ spawn_ping (NMDevice *self,
|
|||
(gchar **) args,
|
||||
NULL,
|
||||
G_SPAWN_DO_NOT_REAP_CHILD,
|
||||
nm_unblock_posix_signals,
|
||||
NULL,
|
||||
NULL,
|
||||
&priv->gw_ping.pid,
|
||||
&error);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
#include "nm-dbus-manager.h"
|
||||
#include "nm-enum-types.h"
|
||||
#include "nm-team-enum-types.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "gsystem-local-alloc.h"
|
||||
|
||||
|
|
@ -433,12 +432,6 @@ teamd_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
*/
|
||||
pid_t pid = getpid ();
|
||||
setpgid (pid, pid);
|
||||
|
||||
/*
|
||||
* We blocked signals in main(). We need to restore original signal
|
||||
* mask for avahi-autoipd here so that it can receive signals.
|
||||
*/
|
||||
nm_unblock_posix_signals (NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -463,7 +456,7 @@ teamd_kill (NMDeviceTeam *self, const char *teamd_binary, GError **error)
|
|||
g_ptr_array_add (argv, NULL);
|
||||
|
||||
_LOGD (LOGD_TEAM, "running: %s", (tmp_str = g_strjoinv (" ", (gchar **) argv->pdata)));
|
||||
return g_spawn_sync ("/", (char **) argv->pdata, NULL, 0, nm_unblock_posix_signals, NULL, NULL, NULL, NULL, error);
|
||||
return g_spawn_sync ("/", (char **) argv->pdata, NULL, 0, NULL, NULL, NULL, NULL, NULL, error);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@
|
|||
#include "nm-logging.h"
|
||||
#include "nm-dhcp-dhclient-utils.h"
|
||||
#include "nm-dhcp-manager.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-dhcp-listener.h"
|
||||
#include "gsystem-local-alloc.h"
|
||||
|
|
@ -307,12 +306,6 @@ dhclient_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
/* We are in the child process at this point */
|
||||
pid_t pid = getpid ();
|
||||
setpgid (pid, pid);
|
||||
|
||||
/*
|
||||
* We blocked signals in main(). We need to restore original signal
|
||||
* mask for dhclient here so that it can receive signals.
|
||||
*/
|
||||
nm_unblock_posix_signals (NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@
|
|||
#include "nm-dhcp-manager.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-dhcp-listener.h"
|
||||
|
||||
|
|
@ -65,12 +64,6 @@ dhcpcd_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
/* We are in the child process at this point */
|
||||
pid_t pid = getpid ();
|
||||
setpgid (pid, pid);
|
||||
|
||||
/*
|
||||
* We blocked signals in main(). We need to restore original signal
|
||||
* mask for dhcpcd here so that it can receive signals.
|
||||
*/
|
||||
nm_unblock_posix_signals (NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@
|
|||
#include "nm-ip6-config.h"
|
||||
#include "nm-logging.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "nm-config.h"
|
||||
|
||||
#include "nm-dns-plugin.h"
|
||||
|
|
@ -238,12 +237,6 @@ netconfig_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
{
|
||||
pid_t pid = getpid ();
|
||||
setpgid (pid, pid);
|
||||
|
||||
/*
|
||||
* We blocked signals in main(). We need to restore original signal
|
||||
* mask for netconfig here so that it can receive signals.
|
||||
*/
|
||||
nm_unblock_posix_signals (NULL);
|
||||
}
|
||||
|
||||
static GPid
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "nm-dns-plugin.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -142,12 +141,6 @@ child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
/* We are in the child process at this point */
|
||||
pid_t pid = getpid ();
|
||||
setpgid (pid, pid);
|
||||
|
||||
/*
|
||||
* We blocked signals in main(). We need to restore original signal
|
||||
* mask for DNS plugin here so that it can receive signals.
|
||||
*/
|
||||
nm_unblock_posix_signals (NULL);
|
||||
}
|
||||
|
||||
GPid
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include "nm-dnsmasq-utils.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "nm-utils.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
|
|
@ -302,12 +301,6 @@ dm_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
/* We are in the child process at this point */
|
||||
pid_t pid = getpid ();
|
||||
setpgid (pid, pid);
|
||||
|
||||
/*
|
||||
* We blocked signals in main(). We need to restore original signal
|
||||
* mask for dnsmasq here so that it can receive signals.
|
||||
*/
|
||||
nm_unblock_posix_signals (NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
112
src/main-utils.c
112
src/main-utils.c
|
|
@ -31,105 +31,63 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib-unix.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
#include "gsystem-local-alloc.h"
|
||||
#include "main-utils.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-logging.h"
|
||||
|
||||
static sigset_t signal_set;
|
||||
static gboolean *quit_early = NULL;
|
||||
|
||||
/*
|
||||
* Thread function waiting for signals and processing them.
|
||||
* Wait for signals in signal set. The semantics of sigwait() require that all
|
||||
* threads (including the thread calling sigwait()) have the signal masked, for
|
||||
* reliable operation. Otherwise, a signal that arrives while this thread is
|
||||
* not blocked in sigwait() might be delivered to another thread.
|
||||
*/
|
||||
static void *
|
||||
signal_handling_thread (void *arg)
|
||||
static gboolean
|
||||
sighup_handler (gpointer user_data)
|
||||
{
|
||||
GMainLoop *main_loop = arg;
|
||||
int signo;
|
||||
/* Reread config stuff like system config files, VPN service files, etc */
|
||||
nm_main_config_reload ();
|
||||
|
||||
while (1) {
|
||||
sigwait (&signal_set, &signo);
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
||||
switch (signo) {
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
nm_log_info (LOGD_CORE, "caught signal %d, shutting down normally.", signo);
|
||||
*quit_early = TRUE; /* for quitting before entering the main loop */
|
||||
g_main_loop_quit (main_loop);
|
||||
break;
|
||||
case SIGHUP:
|
||||
/* Reread config stuff like system config files, VPN service files, etc */
|
||||
nm_main_config_reload ();
|
||||
break;
|
||||
case SIGPIPE:
|
||||
/* silently ignore signal */
|
||||
break;
|
||||
default:
|
||||
nm_log_err (LOGD_CORE, "caught unexpected signal %d", signo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
static gboolean
|
||||
sigint_handler (gpointer user_data)
|
||||
{
|
||||
GMainLoop *main_loop = user_data;
|
||||
|
||||
nm_log_info (LOGD_CORE, "caught SIGINT, shutting down normally.");
|
||||
g_main_loop_quit (main_loop);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sigterm_handler (gpointer user_data)
|
||||
{
|
||||
GMainLoop *main_loop = user_data;
|
||||
|
||||
nm_log_info (LOGD_CORE, "caught SIGTERM, shutting down normally.");
|
||||
g_main_loop_quit (main_loop);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_main_utils_setup_signals:
|
||||
* @main_loop: the #GMainLoop to quit when SIGINT or SIGTERM is received
|
||||
* @quit_early: location of a variable that will be set to TRUE when
|
||||
* SIGINT or SIGTERM is received
|
||||
*
|
||||
* Mask the signals we are interested in and create a signal handling thread.
|
||||
* Because all threads inherit the signal mask from their creator, all threads
|
||||
* in the process will have the signals masked. That's why setup_signals() has
|
||||
* to be called before creating other threads.
|
||||
*
|
||||
* Returns: %TRUE on success
|
||||
* Sets up signal handling for NetworkManager.
|
||||
*/
|
||||
gboolean
|
||||
nm_main_utils_setup_signals (GMainLoop *main_loop, gboolean *quit_early_ptr)
|
||||
void
|
||||
nm_main_utils_setup_signals (GMainLoop *main_loop)
|
||||
{
|
||||
pthread_t signal_thread_id;
|
||||
sigset_t old_sig_mask;
|
||||
int status;
|
||||
g_return_if_fail (main_loop != NULL);
|
||||
|
||||
g_return_val_if_fail (main_loop != NULL, FALSE);
|
||||
g_return_val_if_fail (quit_early_ptr != NULL, FALSE);
|
||||
signal (SIGPIPE, SIG_IGN);
|
||||
|
||||
quit_early = quit_early_ptr;
|
||||
|
||||
sigemptyset (&signal_set);
|
||||
sigaddset (&signal_set, SIGHUP);
|
||||
sigaddset (&signal_set, SIGINT);
|
||||
sigaddset (&signal_set, SIGTERM);
|
||||
sigaddset (&signal_set, SIGPIPE);
|
||||
|
||||
/* Block all signals of interest. */
|
||||
status = pthread_sigmask (SIG_BLOCK, &signal_set, &old_sig_mask);
|
||||
if (status != 0) {
|
||||
fprintf (stderr, _("Failed to set signal mask: %d"), status);
|
||||
return FALSE;
|
||||
}
|
||||
/* Save original mask so that we could use it for child processes. */
|
||||
nm_save_original_signal_mask (old_sig_mask);
|
||||
|
||||
/* Create the signal handling thread. */
|
||||
status = pthread_create (&signal_thread_id, NULL, signal_handling_thread, main_loop);
|
||||
if (status != 0) {
|
||||
fprintf (stderr, _("Failed to create signal handling thread: %d"), status);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
g_unix_signal_add (SIGHUP, sighup_handler, NULL);
|
||||
g_unix_signal_add (SIGINT, sigint_handler, main_loop);
|
||||
g_unix_signal_add (SIGTERM, sigterm_handler, main_loop);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
void nm_main_utils_ensure_root (void);
|
||||
|
||||
gboolean nm_main_utils_setup_signals (GMainLoop *main_loop, gboolean *quit_early_ptr);
|
||||
void nm_main_utils_setup_signals (GMainLoop *main_loop);
|
||||
|
||||
void nm_main_utils_ensure_rundir (void);
|
||||
|
||||
|
|
|
|||
11
src/main.c
11
src/main.c
|
|
@ -54,7 +54,6 @@
|
|||
#include "nm-vpn-manager.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-config.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "nm-session-monitor.h"
|
||||
#include "nm-dispatcher.h"
|
||||
#include "nm-settings.h"
|
||||
|
|
@ -69,7 +68,7 @@
|
|||
#define NM_DEFAULT_SYSTEM_STATE_FILE NMSTATEDIR "/NetworkManager.state"
|
||||
|
||||
static GMainLoop *main_loop = NULL;
|
||||
static gboolean quit_early = FALSE;
|
||||
static gboolean configure_and_quit = FALSE;
|
||||
|
||||
static struct {
|
||||
gboolean show_version;
|
||||
|
|
@ -226,7 +225,7 @@ manager_configure_quit (NMManager *manager, gpointer user_data)
|
|||
{
|
||||
nm_log_info (LOGD_CORE, "quitting now that startup is complete");
|
||||
g_main_loop_quit (main_loop);
|
||||
quit_early = TRUE;
|
||||
configure_and_quit = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -400,8 +399,7 @@ main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Set up unix signal handling - before creating threads, but after daemonizing! */
|
||||
if (!nm_main_utils_setup_signals (main_loop, &quit_early))
|
||||
exit (1);
|
||||
nm_main_utils_setup_signals (main_loop);
|
||||
|
||||
nm_logging_syslog_openlog (global_opt.debug);
|
||||
|
||||
|
|
@ -516,8 +514,7 @@ main (int argc, char *argv[])
|
|||
|
||||
success = TRUE;
|
||||
|
||||
/* Told to quit before getting to the mainloop by the signal handler */
|
||||
if (!quit_early)
|
||||
if (configure_and_quit == FALSE)
|
||||
g_main_loop_run (main_loop);
|
||||
|
||||
nm_manager_stop (manager);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@
|
|||
#include "nm-device.h"
|
||||
#include "nm-active-connection.h"
|
||||
#include "nm-settings-connection.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "nm-auth-subject.h"
|
||||
|
||||
G_DEFINE_TYPE (NMActRequest, nm_act_request, NM_TYPE_ACTIVE_CONNECTION)
|
||||
|
|
@ -202,8 +201,6 @@ share_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
/* We are in the child process at this point */
|
||||
pid_t pid = getpid ();
|
||||
setpgid (pid, pid);
|
||||
|
||||
nm_unblock_posix_signals (NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include "nm-dcb.h"
|
||||
#include "nm-platform.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "nm-logging.h"
|
||||
|
||||
static const char *helper_names[] = { "dcbtool", "fcoeadm" };
|
||||
|
|
@ -305,7 +304,7 @@ run_helper (char **argv, guint which, gpointer user_data, GError **error)
|
|||
nm_log_dbg (LOGD_DCB, "%s", cmdline);
|
||||
|
||||
success = g_spawn_sync ("/", argv, NULL, 0 /*G_SPAWN_DEFAULT*/,
|
||||
nm_unblock_posix_signals, NULL,
|
||||
NULL, NULL,
|
||||
&outmsg, &errmsg, &exit_status, error);
|
||||
/* Log any stderr output */
|
||||
if (success && WIFEXITED (exit_status) && WEXITSTATUS (exit_status) && (errmsg || outmsg)) {
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2012 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "nm-posix-signals.h"
|
||||
|
||||
|
||||
/* Stores the original signal mask of NetworkManager process */
|
||||
static sigset_t nm_original_signal_mask;
|
||||
|
||||
void
|
||||
nm_save_original_signal_mask (sigset_t sig_mask)
|
||||
{
|
||||
nm_original_signal_mask = sig_mask;
|
||||
}
|
||||
|
||||
const sigset_t *
|
||||
nm_get_original_signal_mask (void)
|
||||
{
|
||||
return &nm_original_signal_mask;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unblock signals.
|
||||
* If a signal set is passed, those signals are unblocked. If user_data is NULL
|
||||
* the process' signal mask is set to the saved original mask.
|
||||
* Note: This function can be used in g_spawn_* as GSpawnChildSetupFunc()
|
||||
* callback.
|
||||
*/
|
||||
void
|
||||
nm_unblock_posix_signals (gpointer user_data)
|
||||
{
|
||||
sigset_t *user_sigset = (sigset_t *) user_data;
|
||||
|
||||
if (user_sigset != NULL) {
|
||||
pthread_sigmask (SIG_UNBLOCK, user_sigset, NULL);
|
||||
} else {
|
||||
const sigset_t *orig_sig_mask = nm_get_original_signal_mask ();
|
||||
pthread_sigmask (SIG_SETMASK, orig_sig_mask, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/* NetworkManager -- Network link manager
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright (C) 2012 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NETWORKMANAGER_POSIX_SIGNALS_H__
|
||||
#define __NETWORKMANAGER_POSIX_SIGNALS_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <signal.h>
|
||||
|
||||
/*
|
||||
* This function can be used in g_spawn_* as GSpawnChildSetupFunc()
|
||||
* callback.
|
||||
*/
|
||||
void nm_unblock_posix_signals (gpointer user_data);
|
||||
|
||||
void nm_save_original_signal_mask (sigset_t sig_mask);
|
||||
const sigset_t *nm_get_original_signal_mask (void);
|
||||
|
||||
#endif /* __NETWORKMANAGER_POSIX_SIGNALS_H__ */
|
||||
|
|
@ -47,7 +47,6 @@
|
|||
#include "nm-ppp-manager.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
|
|
@ -1036,12 +1035,6 @@ pppd_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
/* We are in the child process at this point */
|
||||
pid_t pid = getpid ();
|
||||
setpgid (pid, pid);
|
||||
|
||||
/*
|
||||
* We blocked signals in main(). We need to restore original signal
|
||||
* mask for pppd here so that it can receive signals.
|
||||
*/
|
||||
nm_unblock_posix_signals (NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
#include "nm-core-internal.h"
|
||||
#include "nm-platform.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-logging.h"
|
||||
|
||||
|
|
@ -52,12 +51,6 @@ iscsiadm_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
*/
|
||||
pid_t pid = getpid ();
|
||||
setpgid (pid, pid);
|
||||
|
||||
/*
|
||||
* We blocked signals in main(). We need to restore original signal
|
||||
* mask for iscsiadm here so that it can receive signals.
|
||||
*/
|
||||
nm_unblock_posix_signals (NULL);
|
||||
}
|
||||
|
||||
/* Removes trailing whitespace and whitespace before and immediately after the '=' */
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@
|
|||
#include <nm-utils.h>
|
||||
|
||||
#include "nm-platform.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-logging.h"
|
||||
#include "gsystem-local-alloc.h"
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
#include "nm-vpn-service.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-posix-signals.h"
|
||||
#include "nm-vpn-manager.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
|
|
@ -173,12 +172,6 @@ _daemon_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
/* We are in the child process at this point */
|
||||
pid_t pid = getpid ();
|
||||
setpgid (pid, pid);
|
||||
|
||||
/*
|
||||
* We blocked signals in main(). We need to restore original signal
|
||||
* mask for VPN service here so that it can receive signals.
|
||||
*/
|
||||
nm_unblock_posix_signals (NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue