diff options
author | Debarshi Ray <debarshir@gnome.org> | 2018-06-22 13:19:56 +0200 |
---|---|---|
committer | Debarshi Ray <debarshir@gnome.org> | 2018-06-22 14:58:57 +0200 |
commit | 9bc337f9830109b2138bfeb2ee70f9481c3c549a (patch) | |
tree | f4d3b1b363f3106fa395cfbfd70051900fe6971a | |
parent | a88f8c27542203ee2cbb7f000aa1b760828486ef (diff) | |
download | vte-wip/rishi/issue-7.tar.gz |
widget: Make vte_terminal_spawn_async match its synchronous variantwip/rishi/issue-7
It doesn't cause any visible change in behaviour on its own.
However, for downstreams that continue to use gnome-pty-helper, this
avoids a race condition where the helper closes its copy of the
pseudo-terminal slave file descriptor right after VteTerminal has
started polling the master for input, but before the child process has
been forked. This causes VteTerminal to receive a G_IO_HUP and it
stops reading the master for further input. The subsequently forked
child process gets left in a defunct state, and this CRITICAL is
logged:
Vte-CRITICAL **: void vte_terminal_watch_child(VteTerminal*, GPid):
assertion 'impl->m_pty != NULL' failed
Polling the pseudo-terminal master device after the child process has
been set up, avoids this race because the child keeps its copy of the
slave file descriptor open. This prevents VteTerminal from receiving
any G_IO_HUP even if the helper closes its copy afterwards.
Fixes GNOME/vte#7:
https://gitlab.gnome.org/GNOME/vte/issues/7
-rw-r--r-- | src/vtegtk.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/vtegtk.cc b/src/vtegtk.cc index 9e541be1..c435b55c 100644 --- a/src/vtegtk.cc +++ b/src/vtegtk.cc @@ -2543,10 +2543,12 @@ spawn_async_cb (GObject *source, /* Automatically watch the child */ if (terminal != nullptr) { - if (pid != -1) + if (pid != -1) { + vte_terminal_set_pty(terminal, pty); vte_terminal_watch_child(terminal, pid); - else + } else { vte_terminal_set_pty(terminal, nullptr); + } } else { if (pid != -1) { vte_reaper_add_child(pid); @@ -2671,8 +2673,6 @@ vte_terminal_spawn_async(VteTerminal *terminal, return; } - vte_terminal_set_pty(terminal, pty); - guint spawn_flags = (guint)spawn_flags_; /* We do NOT support this flag. If you want to have some FD open in the child |