summaryrefslogtreecommitdiff
path: root/src/vtespawn.hh
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2020-04-27 20:49:04 +0200
committerChristian Persch <chpe@src.gnome.org>2020-04-27 20:49:04 +0200
commit80a583842f9d013f63d80c469c4b7eace2c03414 (patch)
tree1bcabad06f6d1666c1f610e7166276baf9d6cc6e /src/vtespawn.hh
parent3911b3ee1a6a00cf78d277812f52df8423bec989 (diff)
downloadvte-80a583842f9d013f63d80c469c4b7eace2c03414.tar.gz
spawn: Rework spawning
The old spawning code was copied from glib, and used a thread to make the synchronous variant into an asynchronous one. This had the problem that fork(3p) was called from the worker thread, not the calling (main) thread. The new code replaces this with a two-stage approach where the fork takes place on the calling thread, and only the async wait for the child error is done in a worker thread. This also unifies the sync and async spawn variants to use the exact same code, only called in one or two stages. This also removes calls to setenv/unsetenv from the child setup code, which are not safe to do there. Instead, the environment is prepared in advance and used via execve(2). Fixes: https://gitlab.gnome.org/GNOME/vte/-/issues/118
Diffstat (limited to 'src/vtespawn.hh')
-rw-r--r--src/vtespawn.hh32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/vtespawn.hh b/src/vtespawn.hh
index 89c752be..855394e6 100644
--- a/src/vtespawn.hh
+++ b/src/vtespawn.hh
@@ -22,13 +22,25 @@
#include <glib.h>
-gboolean vte_spawn_async_cancellable (const gchar *working_directory,
- gchar **argv,
- gchar **envp,
- GSpawnFlags flags,
- GSpawnChildSetupFunc child_setup,
- gpointer user_data,
- GPid *child_pid,
- gint timeout,
- GPollFD *pollfd,
- GError **error);
+void _vte_cloexec_from(int fd);
+
+char** _vte_merge_envv(char** envp,
+ char const* cwd,
+ bool inherit);
+
+int _vte_execute(char const* file,
+ char** argv,
+ char** envp,
+ bool search_path,
+ bool search_path_from_envp);
+
+bool _vte_read_ints(int fd,
+ int* buf,
+ int n_ints_in_buf,
+ int *n_ints_read,
+ int timeout,
+ GPollFD *cancellable_pollfd,
+ GError **error);
+
+void _vte_write_err (int fd,
+ int msg);