From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alan Third Newsgroups: gmane.emacs.bugs Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Date: Fri, 9 Nov 2018 00:07:41 +0000 Message-ID: <20181109000741.GA15142@breton.holly.idiocy.org> References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1541721989 26556 195.159.176.226 (9 Nov 2018 00:06:29 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Nov 2018 00:06:29 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 33154@debbugs.gnu.org, Filipp Gunbin To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 09 01:06:25 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKuJd-0006nA-2e for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Nov 2018 01:06:25 +0100 Original-Received: from localhost ([::1]:59558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKuLj-0001Nf-FN for geb-bug-gnu-emacs@m.gmane.org; Thu, 08 Nov 2018 19:08:35 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gKuLV-00018D-FZ for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 19:08:26 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gKuLC-0007dX-PZ for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 19:08:10 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37755) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gKuLC-0007dD-FE for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 19:08:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gKuLC-0006QR-72 for bug-gnu-emacs@gnu.org; Thu, 08 Nov 2018 19:08:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Nov 2018 00:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33154 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.154172207324683 (code B ref 33154); Fri, 09 Nov 2018 00:08:02 +0000 Original-Received: (at 33154) by debbugs.gnu.org; 9 Nov 2018 00:07:53 +0000 Original-Received: from localhost ([127.0.0.1]:42013 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKuL2-0006Q2-TS for submit@debbugs.gnu.org; Thu, 08 Nov 2018 19:07:53 -0500 Original-Received: from mail-wr1-f53.google.com ([209.85.221.53]:36828) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKuL0-0006Pp-N2 for 33154@debbugs.gnu.org; Thu, 08 Nov 2018 19:07:51 -0500 Original-Received: by mail-wr1-f53.google.com with SMTP id z13-v6so90170wrs.3 for <33154@debbugs.gnu.org>; Thu, 08 Nov 2018 16:07:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=7VnYi+lFa2ro+sWPCv+BazeA6UgBFGdSUvOIaY1St3c=; b=PEFej0K+O/oXuAtocnEyL33x4XEztoJbUL2OlUftBwn1RoW9owpkyORDQSYokTgDzd VDwqKBgXVCoEG7vG+ORyhIIQdgGg8bCBZb/rLkKO8GClNH1BaAo+/CaTYwgwBxiOfbWY YtweWZkraoTgk2PHcVIAHBWXy4IbajiASeO661vtR0ZYCKePoxFBdOe/nI36mXYU/68W AIpvaC9NLfYj+GIljt2H/ZtFaBIas0+7RzKPWvKya6/zycopMprdhyA0W9PRymfYRIYR 5EZiGsnbaNV0WvWAt47GqpAC8uFVOs7y77lI1gRphl+IexAqLKe6jImxdeYrxG12qIPq Glhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=7VnYi+lFa2ro+sWPCv+BazeA6UgBFGdSUvOIaY1St3c=; b=o3J+38+VpTtzFVy9/VFRv4lyxXzi0vtNoLGLON9tZ1lhEMpf7T5udF5XZwzkb8930a kNDHsQQQQOisJF2xtuYP6axWZNXv+aLGGrspn9NqC9Y+0MjwuPbMbqu457NtBgbJ1iE0 u1FNaNyVgqmwmDTTOklMyTq2hpWOVAvmy7kKZaF4EGnSx+Nc6f+nog9cuKkSDqbSOg/O HREHAxjIVdhid+HhR65poqFToI/B59XF/GPuehSgwehkiBOcIQ9dou+TkYT1Z5wXrNE/ Te0Ee5hBD9xmnLsb7aIHY0fHG8i0d6zUlBoX6i+lBR5LxO2ObAeA5qaShTGvmhs4kWtL yQQg== X-Gm-Message-State: AGRZ1gLnIOkHaFXP+A/G9hqv2qwFOSX+s3zQS2tU2DlDN4Wxj6sGUO2F 5shvy3dLOOAn3M737DgbOV4= X-Google-Smtp-Source: AJdET5dhRkGHCTpjI7YMp81gbOq9DKGUAFm2Pnldvq93jGbzhsXVdNmFmgd4xUaJdRz7pQLcp52L2w== X-Received: by 2002:adf:bc0c:: with SMTP id s12-v6mr6334154wrg.255.1541722064849; Thu, 08 Nov 2018 16:07:44 -0800 (PST) Original-Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-8cfe-35d9-62a3-d426.holly.idiocy.org. [2001:8b0:3f8:8129:8cfe:35d9:62a3:d426]) by smtp.gmail.com with ESMTPSA id t82-v6sm6707169wme.30.2018.11.08.16.07.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Nov 2018 16:07:43 -0800 (PST) Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:152185 Archived-At: 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? -- Alan Third