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

From: Filipp Gunbin <[email-masked]>
Date: Fri, 09 Nov 2018 13:29:55 +0300

On 09/11/2018 00:07 +0000, Alan Third wrote:

> On Tue, Nov 06, 2018 at 11:41:46PM -0800, Paul Eggert wrote:
>> Filipp Gunbin wrote:
>> > In your patch, we don't detach from current (Emacs's) controlling
>> > terminal before doing TIOCSCTTY.
>>
>> Ah, OK. I see also that vfork won't work on Darwin if pty mode is used,
>> since Emacs wants to create a new session and Darwin setsid always fails in
>> a vforked child that has not yet execed.
>>
>> However, your patch introduces another duplicate of the open/TIOCNOTTY/close
>> fallback code, making three duplicates in all. How about if we coalesce
>> these duplicates into a function and then call that function? Also, I think
>> we can call the function from just two places (not three). Furthermore, I
>> think it'd be more robust if Emacs does setsid everywhere (with a fallback
>> to open/TIOCNOTTY/close everywhere TIOCNOTTY is available), not just Darwin.
>> Proposed patch (against master) attached.
>
> I only have two tests I know of to try here and they both pass with
> this patch:
>
> 1. M‐x shell RET bg REST
>
> doesn’t report that there’s no job control.
>
> 2. (benchmark 1 '(call-process "/usr/bin/true" nil nil nil))
>
> Returns times in the order of 3ms, which is what we’d expect to see.
>
> I’m not even sure if they’re really relevant, tbh. Is there anything
> else I should try?

I have one failing case: "M-x shell-command sudo ls -la" reports "sudo:
no tty present and no askpass program specified".  I don't know what to
do about it yet, but we can defer this for later.

Filipp