[gnome-builder] subprocess-supervisor: more reliable process cleanup
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] subprocess-supervisor: more reliable process cleanup
- Date: Sun, 30 Oct 2016 04:58:47 +0000 (UTC)
commit 3eb31309f02ac600e2cba50a14d07017644d80e2
Author: Christian Hergert <chergert redhat com>
Date: Sat Oct 29 21:57:28 2016 -0700
subprocess-supervisor: more reliable process cleanup
Some API we cannot call until ide_subprocess_wait() has returned. To avoid
that, we can just call force_exit() which is safe to call even if the
process has exited (as it will drop signal delivery on the floor after
the pid has exited as pid will be 0).
libide/subprocess/ide-subprocess-supervisor.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/libide/subprocess/ide-subprocess-supervisor.c b/libide/subprocess/ide-subprocess-supervisor.c
index c1b1f9a..467c1b4 100644
--- a/libide/subprocess/ide-subprocess-supervisor.c
+++ b/libide/subprocess/ide-subprocess-supervisor.c
@@ -65,10 +65,7 @@ ide_subprocess_supervisor_reset (IdeSubprocessSupervisor *self)
* subprocess so that when ide_subprocess_supervisor_wait_cb() is called
* it will not be able to match on (priv->subprocess == subprocess).
*/
-
- if (!ide_subprocess_get_if_exited (subprocess) &&
- !ide_subprocess_get_if_signaled (subprocess))
- ide_subprocess_force_exit (subprocess);
+ ide_subprocess_force_exit (subprocess);
}
}
@@ -112,11 +109,18 @@ ide_subprocess_supervisor_finalize (GObject *object)
IdeSubprocessSupervisor *self = (IdeSubprocessSupervisor *)object;
IdeSubprocessSupervisorPrivate *priv = ide_subprocess_supervisor_get_instance_private (self);
- if (priv->subprocess != NULL && !ide_subprocess_get_if_exited (priv->subprocess))
- ide_subprocess_force_exit (priv->subprocess);
+ /*
+ * Subprocess will have completed a wait by this point (or cancelled). It is
+ * safe to call force_exit() either way as it will drop the signal delivery
+ * on the floor if the process has exited.
+ */
+ if (priv->subprocess != NULL)
+ {
+ ide_subprocess_force_exit (priv->subprocess);
+ g_clear_object (&priv->subprocess);
+ }
g_clear_object (&priv->launcher);
- g_clear_object (&priv->subprocess);
G_OBJECT_CLASS (ide_subprocess_supervisor_parent_class)->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]