diff options
author | Christian Persch <chpe@src.gnome.org> | 2020-04-27 20:49:04 +0200 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2020-04-27 20:49:04 +0200 |
commit | 80a583842f9d013f63d80c469c4b7eace2c03414 (patch) | |
tree | 1bcabad06f6d1666c1f610e7166276baf9d6cc6e /src/libc-glue.hh | |
parent | 3911b3ee1a6a00cf78d277812f52df8423bec989 (diff) | |
download | vte-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/libc-glue.hh')
-rw-r--r-- | src/libc-glue.hh | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/libc-glue.hh b/src/libc-glue.hh index 34de20d6..bb497a7e 100644 --- a/src/libc-glue.hh +++ b/src/libc-glue.hh @@ -36,6 +36,8 @@ public: inline constexpr operator int () const noexcept { return m_errsv; } + inline void reset() noexcept { m_errsv = 0; } + private: int m_errsv; }; // class ErrnoSaver @@ -59,17 +61,6 @@ public: FD& operator=(FD& rhs) = delete; -#if 0 - FD& operator=(FD& rhs) noexcept - { - if (&rhs != this) { - reset(); - m_fd = rhs.release(); - } - return *this; - } -#endif - FD& operator=(FD&& rhs) noexcept { reset(); |