From f2654acb1760fd473dffa28abc1b8e25ca1dbbca Mon Sep 17 00:00:00 2001
From: leigh123linux <leigh123linux@googlemail.com>
Date: Sat, 1 Aug 2015 15:14:32 +0100
Subject: [PATCH] Revert "Fix zombie screensavers"
This reverts commit 7db84a08fa05be09a9fc7d75d93601313bc4ab6a.
---
src/gs-window-x11.c | 78 +++++++++++++++++++++--------------------------------
1 file changed, 31 insertions(+), 47 deletions(-)
diff --git a/src/gs-window-x11.c b/src/gs-window-x11.c
index 6ed384d..a34f116 100644
--- a/src/gs-window-x11.c
+++ b/src/gs-window-x11.c
@@ -53,7 +53,7 @@ static void remove_command_watches (GSWindow *window);
static void gs_window_show_screensaver (GSWindow *window);
static void gs_window_hide_screensaver (GSWindow *window);
-static void screensaver_command_finish (GSWindow *window);
+static void gs_window_kill_screensaver (GSWindow *window);
static gboolean spawn_on_window (GSWindow *window, char *command, int *pid, GIOFunc watch_func, gpointer user_data, gint *watch_id);
@@ -642,26 +642,7 @@ create_screensaver_socket (GSWindow *window,
gtk_socket_add_id (GTK_SOCKET (window->priv->screensaver), id);
gs_window_show_screensaver (window);
}
-
-/* adapted from gspawn.c */
-static int
-wait_on_child (int pid)
-{
- int status;
-
- wait_again:
- if (waitpid (pid, &status, 0) < 0) {
- if (errno == EINTR) {
- goto wait_again;
- } else if (errno == ECHILD) {
- ; /* do nothing, child already reaped */
- } else {
- gs_debug ("waitpid () should not fail in 'GSWindow'");
- }
- }
-
- return status;
-}
+
static gboolean
screensaver_command_watch (GIOChannel *source,
@@ -709,14 +690,14 @@ screensaver_command_watch (GIOChannel *source,
if (finished) {
window->priv->screensaver_watch_id = 0;
- screensaver_command_finish (window);
-
+ gs_window_kill_screensaver (window);
return FALSE;
}
return TRUE;
}
+
static void
gs_window_real_show (GtkWidget *widget)
{
@@ -1157,6 +1138,25 @@ create_keyboard_socket (GSWindow *window,
gtk_socket_add_id (GTK_SOCKET (window->priv->keyboard_socket), id);
}
+/* adapted from gspawn.c */
+static int
+wait_on_child (int pid)
+{
+ int status;
+
+ wait_again:
+ if (waitpid (pid, &status, 0) < 0) {
+ if (errno == EINTR) {
+ goto wait_again;
+ } else if (errno == ECHILD) {
+ ; /* do nothing, child already reaped */
+ } else {
+ gs_debug ("waitpid () should not fail in 'GSWindow'");
+ }
+ }
+
+ return status;
+}
static void
kill_keyboard_command (GSWindow *window)
@@ -1189,36 +1189,20 @@ gs_window_hide_screensaver (GSWindow *window) {
}
static void
-kill_screensaver_command (GSWindow *window)
-{
- if (window->priv->screensaver_pid > 0) {
- signal_pid (window->priv->screensaver_pid, SIGTERM);
- }
-}
-
-static void
-screensaver_command_finish (GSWindow *window)
+gs_window_kill_screensaver (GSWindow *window)
{
- g_return_if_fail (GS_IS_WINDOW (window));
-
- gs_debug ("Screensaver finished");
-
gs_window_hide_screensaver (window);
-
if (window->priv->screensaver) {
gtk_widget_destroy (window->priv->screensaver);
window->priv->screensaver = NULL;
}
-
- kill_screensaver_command (window);
-
if (window->priv->screensaver_pid > 0) {
window->priv->screensaver_watch_id = 0;
+ signal_pid (window->priv->screensaver_pid, SIGTERM);
+ wait_on_child (window->priv->lock_pid);
- wait_on_child (window->priv->screensaver_pid);
- g_spawn_close_pid (window->priv->screensaver_pid);
-
- window->priv->screensaver_pid = 0;
+ g_spawn_close_pid (window->priv->lock_pid);
+ window->priv->lock_pid = 0;
}
}
@@ -1356,7 +1340,7 @@ gs_window_dialog_finish (GSWindow *window)
gs_debug ("Dialog finished");
- /* make sure we finish the keyboard and screensaver thing too */
+ /* make sure we finish the keyboard thing too */
keyboard_command_finish (window);
/* send a signal just in case */
@@ -1528,7 +1512,7 @@ lock_command_watch (GIOChannel *source,
popdown_dialog (window);
if (window->priv->dialog_response == DIALOG_RESPONSE_OK) {
- kill_screensaver_command (window);
+ gs_window_kill_screensaver (window);
add_emit_deactivated_idle (window);
}
@@ -1540,6 +1524,7 @@ lock_command_watch (GIOChannel *source,
return TRUE;
}
+
static gboolean
is_logout_enabled (GSWindow *window)
{
@@ -2577,7 +2562,6 @@ gs_window_finalize (GObject *object)
remove_command_watches (window);
- screensaver_command_finish (window);
gs_window_dialog_finish (window);
if (window->priv->background_surface) {
--
2.5.0