unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Filipp Gunbin <fgunbin@fastmail.fm>
To: 33154@debbugs.gnu.org
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	[thread overview]
Message-ID: <m2va59wtyb.fsf@fastmail.fm> (raw)
In-Reply-To: <20181026111227.GA48441@breton.holly.idiocy.org> (Alan Third's message of "Fri, 26 Oct 2018 12:12:27 +0100")

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)
 	{





  reply	other threads:[~2018-11-07  1:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25 19:30 bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Filipp Gunbin
2018-10-26 11:12 ` Alan Third
2018-11-07  1:35   ` Filipp Gunbin [this message]
2018-11-05 17:28 ` Paul Eggert
2018-11-06 13:46   ` Filipp Gunbin
2018-11-07  1:23   ` Filipp Gunbin
2018-11-07  7:41     ` Paul Eggert
2018-11-07  8:53       ` Filipp Gunbin
2018-11-07 15:40         ` Paul Eggert
2018-11-09  0:07       ` Alan Third
2018-11-09 10:29         ` Filipp Gunbin
2018-11-09 11:16           ` Andreas Schwab
2018-11-10 15:24             ` Filipp Gunbin
2018-11-10 17:09               ` Paul Eggert
2018-11-11 17:14                 ` Filipp Gunbin
2018-11-10 17:05         ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2va59wtyb.fsf@fastmail.fm \
    --to=fgunbin@fastmail.fm \
    --cc=33154@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).