[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#33154: 27.0.50; create_process on Darwin should not invoke setsid()
From: |
Filipp Gunbin |
Subject: |
bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] |
Date: |
Wed, 07 Nov 2018 04:35:24 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (darwin) |
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)
{
- bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH], (continued)
- bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH], Paul Eggert, 2018/11/07
- bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH], Alan Third, 2018/11/08
- bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH], Filipp Gunbin, 2018/11/09
- bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH], Andreas Schwab, 2018/11/09
- bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH], Filipp Gunbin, 2018/11/10
- bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH], Paul Eggert, 2018/11/10
- bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH], Filipp Gunbin, 2018/11/11
- bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH], Paul Eggert, 2018/11/10
bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH],
Filipp Gunbin <=