[vte] spawn: Don't allow G_SPAWN_LEAVE_DESCRIPTORS_OPEN flag
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] spawn: Don't allow G_SPAWN_LEAVE_DESCRIPTORS_OPEN flag
- Date: Thu, 14 Jan 2016 16:10:09 +0000 (UTC)
commit ca705122f1638cbf8c4119ff6bfab7e974e01256
Author: Christian Persch <chpe gnome org>
Date: Thu Jan 14 17:05:33 2016 +0100
spawn: Don't allow G_SPAWN_LEAVE_DESCRIPTORS_OPEN flag
If you do want to pass a FD to the child, use a child setup
function that unsets the FD_CLOEXEC flag.
src/vte.cc | 10 ++++++----
src/vtegtk.cc | 7 ++++---
2 files changed, 10 insertions(+), 7 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 570f122..e6f4bcb 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -3600,10 +3600,6 @@ VteTerminalPrivate::watch_child (GPid child_pid)
*
* Note that %G_SPAWN_DO_NOT_REAP_CHILD will always be added to @spawn_flags.
*
- * Note that unless @spawn_flags contains %G_SPAWN_LEAVE_DESCRIPTORS_OPEN, all file
- * descriptors except stdin/stdout/stderr will be closed before calling exec()
- * in the child.
- *
* See vte_pty_new(), g_spawn_async() and vte_terminal_watch_child() for more information.
*
* Returns: %TRUE on success, or %FALSE on error with @error filled in
@@ -3635,6 +3631,12 @@ VteTerminalPrivate::spawn_sync(VtePtyFlags pty_flags,
/* FIXMEchpe: is this flag needed */
spawn_flags |= G_SPAWN_CHILD_INHERITS_STDIN;
+ /* We do NOT support this flag. If you want to have some FD open in the child
+ * process, simply use a child setup function that unsets the CLOEXEC flag
+ * on that FD.
+ */
+ spawn_flags &= ~G_SPAWN_LEAVE_DESCRIPTORS_OPEN;
+
if (!__vte_pty_spawn(new_pty,
working_directory,
argv,
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 3e62eec..fb14d46 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -2208,9 +2208,10 @@ vte_terminal_watch_child (VteTerminal *terminal,
*
* Note that %G_SPAWN_DO_NOT_REAP_CHILD will always be added to @spawn_flags.
*
- * Note that unless @spawn_flags contains %G_SPAWN_LEAVE_DESCRIPTORS_OPEN, all file
- * descriptors except stdin/stdout/stderr will be closed before calling exec()
- * in the child.
+ * Note that all open file descriptors will be closed in the child. If you want
+ * to keep some file descriptor open for use in the child process, you need to
+ * use a child setup function that unsets the FD_CLOEXEC flag on that file
+ * descriptor.
*
* See vte_pty_new(), g_spawn_async() and vte_terminal_watch_child() for more information.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]