Subject: Re: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH]

From: Alan Third <[email-masked]>
Date: Fri, 26 Oct 2018 12:12:27 +0100

On Thu, Oct 25, 2018 at 10:30:12PM +0300, Filipp Gunbin wrote:
> This resulted from analysis of bug 33050.  To avoid repetition, here's
> the message with explanation:
> http://lists.gnu.org/archive/html/bug-gnu-emacs/2018-10/msg00763.html

Sorry, I didn’t notice the other emails before now.

This looks fine to me, but I’m no expert on this stuff.

Just one point, though:

>        /* Make the pty be the controlling terminal of the process.  */
>  #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. */
> +      {
> +	int j = emacs_open (DEV_TTY, O_RDWR, 0);
> +	if (j >= 0)
> +	  {
> +	    ioctl (j, TIOCNOTTY, 0);
> +	    emacs_close (j);
> +	  }
> +      }
> +#else
>        setsid ();
> +#endif

The main block of this code looks identical to the BSD specific code
just underneath (#ifdef TIOCNOTTY), is there a reason we can’t reuse
that?

-- 
Alan Third