summary refs log tree commit diff
path: root/callouts/nm-dispatcher.c
diff options
context:
space:
mode:
Diffstat (limited to 'callouts/nm-dispatcher.c')
-rw-r--r--callouts/nm-dispatcher.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/callouts/nm-dispatcher.c b/callouts/nm-dispatcher.c
index 0cd2531d..09eb0d3a 100644
--- a/callouts/nm-dispatcher.c
+++ b/callouts/nm-dispatcher.c
@@ -294,9 +294,12 @@ script_timeout_cb (gpointer user_data)
 
 	g_warning ("Script '%s' took too long; killing it.", script->script);
 
-	if (kill (script->pid, 0) == 0)
-		kill (script->pid, SIGKILL);
-	(void) waitpid (script->pid, NULL, 0);
+	kill (script->pid, SIGKILL);
+again:
+	if (waitpid (script->pid, NULL, 0) == -1) {
+		if (errno == EINTR)
+			goto again;
+	}
 
 	script->error = g_strdup_printf ("Script '%s' timed out.", script->script);
 	script->result = DISPATCH_RESULT_TIMEOUT;
@@ -361,15 +364,6 @@ check_filename (const char *file_name)
 	return TRUE;
 }
 
-static void
-child_setup (gpointer user_data G_GNUC_UNUSED)
-{
-	/* We are in the child process at this point */
-	/* Give child a different process group to ensure signal separation. */
-	pid_t pid = getpid ();
-	setpgid (pid, pid);
-}
-
 #define SCRIPT_TIMEOUT 600  /* 10 minutes */
 
 static void
@@ -387,7 +381,7 @@ dispatch_one_script (Request *request)
 	if (request->debug)
 		g_message ("Running script '%s'", script->script);
 
-	if (g_spawn_async ("/", argv, request->envp, G_SPAWN_DO_NOT_REAP_CHILD, child_setup, request, &script->pid, &error)) {
+	if (g_spawn_async ("/", argv, request->envp, G_SPAWN_DO_NOT_REAP_CHILD, NULL, request, &script->pid, &error)) {
 		request->script_watch_id = g_child_watch_add (script->pid, (GChildWatchFunc) script_watch_cb, script);
 		request->script_timeout_id = g_timeout_add_seconds (SCRIPT_TIMEOUT, script_timeout_cb, script);
 	} else {
@@ -555,8 +549,13 @@ on_name_lost (GDBusConnection *connection,
               gpointer         user_data)
 {
 	if (!connection) {
-		g_warning ("Could not get the system bus.  Make sure the message bus daemon is running!");
-		exit (1);
+		if (!ever_acquired_name) {
+			g_warning ("Could not get the system bus.  Make sure the message bus daemon is running!");
+			exit (1);
+		} else {
+			g_message ("System bus stopped. Exiting");
+			exit (0);
+		}
 	} else if (!ever_acquired_name) {
 		g_warning ("Could not acquire the " NM_DISPATCHER_DBUS_SERVICE " service.");
 		exit (1);