GNU bug report logs -
#33154
27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH]
Previous Next
Reported by: Filipp Gunbin <fgunbin <at> fastmail.fm>
Date: Thu, 25 Oct 2018 19:31:02 UTC
Severity: normal
Tags: patch
Found in version 27.0.50
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
Full log
Message #20 received at 33154 <at> debbugs.gnu.org (full text, mbox):
Well, my initial patch fixed the pipe case, but broke the pty case.
That became visible after make bootstrap.
This new patch seems to work. It attempts to handle all cases:
- When not on Darwin, just do vfork() and setsid()
- When on Darwin and pipe mode, do the same as call_process(): vfork(),
then detach from the current controlling terminal via TIOCNOTTY
- When on Darwin and pty mode, do fork() and later setsid(). We should
create new session to be able to use just allocated tty.
I'll use it for some time, then report the result.
Filipp
diff --git a/src/process.c b/src/process.c
index 6cda4f27ac..9125936eb9 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2099,7 +2099,23 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
#ifdef HAVE_PTYS
/* First, disconnect its current controlling terminal.
Do this even if !PTY_FLAG; see Bug#30762. */
+#ifdef DARWIN_OS
+ /* Darwin doesn't let us run setsid after a vfork, so use
+ TIOCNOTTY when necessary. */
+ if (pty_flag)
+ setsid ();
+ else
+ {
+ int j = emacs_open (DEV_TTY, O_RDWR, 0);
+ if (j >= 0)
+ {
+ ioctl (j, TIOCNOTTY, 0);
+ emacs_close (j);
+ }
+ }
+#else
setsid ();
+#endif
/* Make the pty's terminal the controlling terminal. */
if (pty_flag && forkin >= 0)
{
This bug report was last modified 6 years and 275 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.