[gnome-builder] foundry: add open pty helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] foundry: add open pty helper
- Date: Sat, 27 Apr 2019 23:14:19 +0000 (UTC)
commit 121e6b6834bc2a3206c0a57990e2729759393a9d
Author: Christian Hergert <chergert redhat com>
Date: Sat Apr 27 16:12:34 2019 -0700
foundry: add open pty helper
This helps ensure that we keep using the same slave-side PTY fd for the
child processes.
src/libide/foundry/ide-test-manager.c | 33 +++++++++++++++++++++++++++++++++
src/libide/foundry/ide-test-manager.h | 2 ++
2 files changed, 35 insertions(+)
---
diff --git a/src/libide/foundry/ide-test-manager.c b/src/libide/foundry/ide-test-manager.c
index 1d409758d..9b4486e80 100644
--- a/src/libide/foundry/ide-test-manager.c
+++ b/src/libide/foundry/ide-test-manager.c
@@ -23,6 +23,7 @@
#include "config.h"
#include <dazzle.h>
+#include <libide-io.h>
#include <libide-threading.h>
#include <libpeas/peas.h>
@@ -58,6 +59,7 @@ struct _IdeTestManager
GPtrArray *tests_by_provider;
GtkTreeStore *tests_store;
VtePty *pty;
+ gint child_pty;
};
typedef struct
@@ -111,6 +113,12 @@ ide_test_manager_destroy (IdeObject *object)
{
IdeTestManager *self = (IdeTestManager *)object;
+ if (self->child_pty != -1)
+ {
+ close (self->child_pty);
+ self->child_pty = -1;
+ }
+
if (self->tests_store != NULL)
{
gtk_tree_store_clear (self->tests_store);
@@ -175,6 +183,7 @@ ide_test_manager_class_init (IdeTestManagerClass *klass)
static void
ide_test_manager_init (IdeTestManager *self)
{
+ self->child_pty = -1;
self->tests_by_provider = g_ptr_array_new_with_free_func (tests_by_provider_free);
self->tests_store = gtk_tree_store_new (2, G_TYPE_STRING, IDE_TYPE_TEST);
}
@@ -1057,3 +1066,27 @@ ide_test_manager_get_pty (IdeTestManager *self)
return self->pty;
}
+
+/**
+ * ide_test_manager_open_pty:
+ * @self: a #IdeTestManager
+ *
+ * Gets a FD that maps to the child side of the PTY device.
+ *
+ * Returns: a new FD or -1 on failure
+ *
+ * Since: 3.34
+ */
+gint
+ide_test_manager_open_pty (IdeTestManager *self)
+{
+ g_return_val_if_fail (IDE_IS_TEST_MANAGER (self), -1);
+
+ if (self->child_pty == -1)
+ {
+ VtePty *pty = ide_test_manager_get_pty (self);
+ self->child_pty = ide_pty_intercept_create_slave (vte_pty_get_fd (pty), TRUE);
+ }
+
+ return dup (self->child_pty);
+}
diff --git a/src/libide/foundry/ide-test-manager.h b/src/libide/foundry/ide-test-manager.h
index 5f7a87f5f..bbbf950df 100644
--- a/src/libide/foundry/ide-test-manager.h
+++ b/src/libide/foundry/ide-test-manager.h
@@ -42,6 +42,8 @@ IDE_AVAILABLE_IN_3_32
gboolean ide_test_manager_get_loading (IdeTestManager *self);
IDE_AVAILABLE_IN_3_32
VtePty *ide_test_manager_get_pty (IdeTestManager *self);
+IDE_AVAILABLE_IN_3_34
+gint ide_test_manager_open_pty (IdeTestManager *self);
IDE_AVAILABLE_IN_3_32
void ide_test_manager_run_async (IdeTestManager *self,
IdeTest *test,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]