From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Filipp Gunbin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Oct 2018 19:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 33154 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 33154@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.154049585021062 (code B ref -1); Thu, 25 Oct 2018 19:31:02 +0000 Received: (at submit) by debbugs.gnu.org; 25 Oct 2018 19:30:50 +0000 Received: from localhost ([127.0.0.1]:42832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gFlLG-0005Te-Cv for submit@debbugs.gnu.org; Thu, 25 Oct 2018 15:30:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46963) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gFlLF-0005TR-7x for submit@debbugs.gnu.org; Thu, 25 Oct 2018 15:30:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFlL5-0001ub-54 for submit@debbugs.gnu.org; Thu, 25 Oct 2018 15:30:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33026) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFlL2-0001tR-8M for submit@debbugs.gnu.org; Thu, 25 Oct 2018 15:30:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFlL1-00033v-8y for bug-gnu-emacs@gnu.org; Thu, 25 Oct 2018 15:30:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFlKu-0001pp-EQ for bug-gnu-emacs@gnu.org; Thu, 25 Oct 2018 15:30:34 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:54483) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFlKj-0001iv-A9 for bug-gnu-emacs@gnu.org; Thu, 25 Oct 2018 15:30:19 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id AF5C13C5 for ; Thu, 25 Oct 2018 15:30:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 25 Oct 2018 15:30:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:subject:date:message-id:mime-version:content-type; s= fm1; bh=brwJnsGqjJ+XRzMuruEyCpehkA8feT+TSGRx9XmvTIo=; b=U0sE5elR khBGkLsRzZgVLNKilETLxG25RP4sulfA3+8014F50h6hImynCClRB7F9LXuHOgps gbgS0kCvLwT6C1kTBFKwc7wGjAZyWKy+Y6lbekN3CWXUXz4EqpA8xaLSo77VmiIF oOLvx6sCbm3wgou8Ra1ozChByAC8oMbzOjJcgoRUZ2IdH98seGTbV4Cw5I7P7qg8 AwOmjyck685xF4oXbkA+l2JaA9rPe63S2rKnL+cVcUmPlLeXoGUItqoGnJYAnEBj Irev4dHOt7O7fMlpm9J0yrkjrwo9PpnpzGGkwYyWLNrPcMrqa1IE1wf7KINmpc9q WKtb9bocRrwuUg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=brwJnsGqjJ+XRzMuruEyCpehkA8fe T+TSGRx9XmvTIo=; b=EGHsP9cbmDkl4liJg3lsl1h1cDoVRRfdCLh9/TM8G9ZG8 tEteX/6E4u7beZgdZx4UBn0bacP+i29j6XHgrmiA5dWJ7dllpMTAWVIJiLeFVQbe vgV4QSuFzTPhqM8PUjGT9vg+dxpRbz5niIlwkYlkPgcpWDEMxV260+Q5ymM1dBJo Pn1+HR8nknFhlduQg33XXuNhJb35lXuko77o8wofoYgQhf6b6Zw7qzBBpk5CtLJb mMUqPxdveFzUW33IbLu2yGTdAbMF/zOxGil+BXr/SSIHXUqwtU2jATcdT7YRvxHC nxIewUsZA54WR6vF5bJVkd1XKpKfcfzA4mCLPl9iA== X-ME-Sender: X-ME-Proxy: Received: from fgunbin.playteam.ru (unknown [95.161.147.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 93298102F2 for ; Thu, 25 Oct 2018 15:30:14 -0400 (EDT) From: Filipp Gunbin Date: Thu, 25 Oct 2018 22:30:12 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.3 (-----) 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 Suggested patch is below. Thanks. In GNU Emacs 27.0.50 (build 12, x86_64-apple-darwin17.7.0, NS appkit-1561.60 Version 10.13.6 (Build 17G65)) of 2018-10-25 built on fgunbin.playteam.ru Repository revision: f1f1687fcd8d48cd519c0f2977bcecbf394a7f01 System Description: Mac OS X 10.13.6 diff --git a/src/process.c b/src/process.c index 6cda4f27ac..1f8810927d 100644 --- a/src/process.c +++ b/src/process.c @@ -2066,21 +2066,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) int volatile forkerr_volatile = forkerr; struct Lisp_Process *p_volatile = p; -#ifdef DARWIN_OS - /* Darwin doesn't let us run setsid after a vfork, so use fork when - necessary. Also, reset SIGCHLD handling after a vfork, as - apparently macOS can mistakenly deliver SIGCHLD to the child. */ - if (pty_flag) - pid = fork (); - else - { - pid = vfork (); - if (pid == 0) - signal (SIGCHLD, SIG_DFL); - } -#else pid = vfork (); -#endif current_dir = current_dir_volatile; lisp_pty_name = lisp_pty_name_volatile; @@ -2091,15 +2077,35 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) p = p_volatile; pty_flag = p->pty_flag; - if (pid == 0) #endif /* not WINDOWSNT */ { +#ifdef DARWIN_OS + /* Work around a macOS bug, where SIGCHLD is apparently + delivered to a vforked child instead of to its parent. See: + https://lists.gnu.org/r/emacs-devel/2017-05/msg00342.html + */ + signal (SIGCHLD, SIG_DFL); +#endif + /* 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 /* Make the pty's terminal the controlling terminal. */ if (pty_flag && forkin >= 0) { From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Alan Third Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 Oct 2018 11:13: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 To: Filipp Gunbin Cc: 33154@debbugs.gnu.org Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.154055235920568 (code B ref 33154); Fri, 26 Oct 2018 11:13:02 +0000 Received: (at 33154) by debbugs.gnu.org; 26 Oct 2018 11:12:39 +0000 Received: from localhost ([127.0.0.1]:43251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gG02g-0005Lg-N7 for submit@debbugs.gnu.org; Fri, 26 Oct 2018 07:12:38 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:53321) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gG02e-0005LS-W1 for 33154@debbugs.gnu.org; Fri, 26 Oct 2018 07:12:37 -0400 Received: by mail-wm1-f68.google.com with SMTP id l26-v6so1103715wmh.3 for <33154@debbugs.gnu.org>; Fri, 26 Oct 2018 04:12:36 -0700 (PDT) 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=C3pW0tZ0wsLbCe755eH0PpoYhJAjw1i6gSwWAWnYA64=; b=m9DrxklGCyORqxHCGVeq8yQE1yxOlu2RIuDc6lJ+hlEh0hNFesORDj3XhVeKhxIr57 dFDPSY5r3k+tX4HHz3fjYMoWozgfPAiheWDDMdhVzfvMjfyMhPOJkC/jfoPeSfPmzesK R/u36Zx3WNB/a97pk0CESig24R00RbjmjgPkNeLU/l9LWX3nw+NogsvyBqeI/JpnboJr dKbvDDp3z4zM1sEv8ScMCX1tA867TFqQ5KAyUMJ4bflOR9lHRmLMYA/xtz1XAAKr5vg2 Zw92TCAK0d/zTaLB8uHDoS2fOV4Bqkac3QwGCyadHn31nd65/FPi0kcY4izAa6yoSV5i ggXA== 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=C3pW0tZ0wsLbCe755eH0PpoYhJAjw1i6gSwWAWnYA64=; b=SJO9IL9+mEfHvXrTHNuC+Z5K225cef95S6YcMmXXNR7uNT+ChlVsbXWY3DscpxSOcb 08beuoaZ8gtu3VA8wGW3mx79mqHu0lcpZVsEPzu1P1oFaKlzqGACCvAPebjQ3yiihyRC BUX/k/W2PtKetYl6p+eGPtqrx90HhqjP5qAGaCeMRrw2+5I23J5GlfC9VtKxg91UzlSC 7gOzWRZA6fQYq9SZQbxoYJ+Sd2S9k1gfwFHO0W76tq/mlABvlDwqw1kKaCufUEHrG+Yr POfyh81gn9C4D6hVuofMN4qtn6DnrtsoDFBlvAunq93OILs0wntpniyno+X221IHRyCJ W6rw== X-Gm-Message-State: AGRZ1gJPP/2qVXBTblI7gWt8PUK5gDxvuUmWI7oseauAE9HxMlvGJjmZ mzIBVK1FP4Q+BC/l0iwEQHE= X-Google-Smtp-Source: AJdET5da6OnT1zJoJm2vsci9Ca/7cl5YnTyQJdvNWuo4Ev12t3Q8y5RfjA+U+5V3dLe4aq+CBTx93Q== X-Received: by 2002:a1c:b90c:: with SMTP id j12-v6mr5379050wmf.32.1540552351099; Fri, 26 Oct 2018 04:12:31 -0700 (PDT) Received: from breton.holly.idiocy.org (ip6-2001-08b0-03f8-8129-a9a7-73e3-89ce-d96b.holly.idiocy.org. [2001:8b0:3f8:8129:a9a7:73e3:89ce:d96b]) by smtp.gmail.com with ESMTPSA id u13-v6sm7088695wrn.11.2018.10.26.04.12.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Oct 2018 04:12:30 -0700 (PDT) Date: Fri, 26 Oct 2018 12:12:27 +0100 From: Alan Third Message-ID: <20181026111227.GA48441@breton.holly.idiocy.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Score: 0.5 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) 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 From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] References: In-Reply-To: Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Nov 2018 17:29:01 +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 To: Alan Third Cc: 33154@debbugs.gnu.org, Filipp Gunbin Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.154143891824376 (code B ref 33154); Mon, 05 Nov 2018 17:29:01 +0000 Received: (at 33154) by debbugs.gnu.org; 5 Nov 2018 17:28:38 +0000 Received: from localhost ([127.0.0.1]:35523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gJig2-0006L6-G3 for submit@debbugs.gnu.org; Mon, 05 Nov 2018 12:28:38 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:47380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gJifz-0006Kq-9W for 33154@debbugs.gnu.org; Mon, 05 Nov 2018 12:28:36 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 57E7016009F; Mon, 5 Nov 2018 09:28:29 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id sSWp2jgxkkwP; Mon, 5 Nov 2018 09:28:28 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1A5CA16009D; Mon, 5 Nov 2018 09:28:28 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id q6pofJraG0m2; Mon, 5 Nov 2018 09:28:28 -0800 (PST) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id EFF43160099; Mon, 5 Nov 2018 09:28:27 -0800 (PST) From: Paul Eggert Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTYp5bltF3WYDz1Ygd7gx07Auwp7iw7eNvnoDTAl KAl8KYDZzbDNCQGEbpY3efZIvPdeI+FWQN4W+kghy+P6au6PrIIhYraeua7XDdb2LS1en3Ss mE3QjqfRqI/A2ue8JMwsvXe/WK38Ezs6x74iTaqI3AFH6ilAhDqpMnd/msSESNFt76DiO1ZK QMr9amVPknjfPmJISqdhgB1DlEdw34sROf6V8mZw0xfqT6PKE46LcFefzs0kbg4GORf8vjG2 Sf1tk5eU8MBiyN/bZ03bKNjNYMpODDQQwuP84kYLkX2wBxxMAhBxwbDVZudzxDZJ1C2VXujC OJVxq2kljBM9ETYuUGqd75AW2LXrLw6+MuIsHFAYAgRr7+KcwDgBAfwhPBYX34nSSiHlmLC+ KaHLeCLF5ZI2vKm3HEeCTtlOg7xZEONgwzL+fdKo+D6SoC8RRxJKs8a3sVfI4t6CnrQzvJbB n6gxdgCu5i29J1QCYrCYvql2UyFPAK+do99/1jOXT4m2836j1wARAQABzSBQYXVsIEVnZ2Vy dCA8ZWdnZXJ0QGNzLnVjbGEuZWR1PsLBfgQTAQIAKAUCTIByZAIbAwUJEswDAAYLCQgHAwIG FQgCCQoLBBYCAwECHgECF4AACgkQ7ZfpDmKqfjRRGw/+Ij03dhYfYl/gXVRiuzV1gGrbHk+t nfrI/C7fAeoFzQ5tVgVinShaPkZo0HTPf18x6IDEdAiO8Mqo1yp0CtHmzGMCJ50o4Grgfjlr 6g/+vtEOKbhleszN2XpJvpwM2QgGvn/laTLUu8PH9aRWTs7qJJZKKKAb4sxYc92FehPu6FOD 0dDiyhlDAq4lOV2mdBpzQbiojoZzQLMQwjpgCTK2572eK9EOEQySUThXrSIz6ASenp4NYTFH s9tuJQvXk9gZDdPSl3bp+47dGxlxEWLpBIM7zIONw4ks4azgT8nvDZxA5IZHtvqBlJLBObYY 0Le61Wp0y3TlBDh2qdK8eYL426W4scEMSuig5gb8OAtQiBW6k2sGUxxeiv8ovWu8YAZgKJfu oWI+uRnMEddruY8JsoM54KaKvZikkKs2bg1ndtLVzHpJ6qFZC7QVjeHUh6/BmgvdjWPZYFTt N+KA9CWX3GQKKgN3uu988yznD7LnB98T4EUH1HA/GnfBqMV1gpzTvPc4qVQinCmIkEFp83zl +G5fCjJJ3W7ivzCnYo4KhKLpFUm97okTKR2LW3xZzEW4cLSWO387MTK3CzDOx5qe6s4a91Zu ZM/j/TQdTLDaqNn83kA4Hq48UHXYxcIh+Nd8k/3w6lFuoK0wrOFiywjLx+0ur5jmmbecBGHc 1xdhAFHOwU0ETIByZAEQAKaF678T9wyH4wjTrV1Pz3cDEoSnV/0ZUrOT37p1dcGyj/IXq1x6 70HRVahAmk0sZpYc25PF9D5GPYHFWlNjuPU96rDndXB3hedmBRhLdC4bAXjI4DV+bmdVe+q/ IMnlZRaVlm9EiMCVAR6w13sReu7qXkW9r3RwY2AzXskp/tAe4BRKr1Zmbvi2nbnQ6epEC42r Rbx0B1EhjbIQZ5JHGk24iPT7LdBgnNmos5wYjzwNlkMQD5T0Ydzhk7J+UxwA5m46mOhRDC2r FV/A0gm5TLy8DXjv/Esc4gYnYai6SQqnUEVh5LuV8YCJBnijs+Tiw71x1icmn6xGI45EugJO gec+rLypYgpVp4x0HI5T88qBRYCkxH3Kg8Qo+EWNA9A4LRQ9DX8njona0gf0s03tocK8kBN6 6UoqqPtHBnc4eMgBymCflK12eKfd2YYxnyg9cZazWA5VslvTxpm76hbg5oiAEH/Vg/8MxHyA nPhfrgwyPrmJEcVBafdspJnYQxBYNco2LFPIhlOvWh8r4at+s+M3Lb26oUTczlgdW1Sf3SDA 77BMRnF0FQyE+7AzV79MBN4ykiqaezQxtaF1Fy/tvkhffSo8u+dwG0EgJh+te38gTcISVr0G IPplLz6YhjrbHrPRF1CN5UuL9DBGjxuN35RLNVEfta6RUFlR6NctTjvrABEBAAHCwWUEGAEC AA8FAkyAcmQCGwwFCRLMAwAACgkQ7ZfpDmKqfjSrHA/+KzAKvTxRhA9MWNLxIyJ7S5uJ16gs T3oCjZrBKGEhKMOGX4O0GA6VOEryO7QRCCYah3oxSG38IAnNeiwJXgU9Bzkk85UGbPEd7HGF /VSeHCQwWou6jqUDTSDvn9YhNTdG0KXPM74aC+xr2Zow1O2mhXihgWKD0Dw+0LYPnUOsQ0KO FxHXXYHmRrS1OZPU59BLvc+TRhIhafSHKLwbXK+6ckkxBx6h8z5ccpG0Qs4bFhdFYnFrEieD LoGmnE2YLhdV6swJ9VNCS6pLiEohT3fm7aXm15tZOIyzMZhHRSAPblXxQ0ZSWjq8oRrcYNFx c4W1URpAkBCOYJoXvQfD5L3lqAl8TCqDUzYxhH/tJhbDdHrqHH767jaDaTB1+Talp/2AMKwc XNOdiklGxbmHVG6YGl6g8Lrbsu9NZEI4yLlHzuikthJWgz+3vZhVGyNlt+HNIoF6CjDL2omu 5cEq4RDHM44QqPk6l7O0pUvN1mT4B+S1b08RKpqm/ff015E37HNV/piIvJlxGAYz8PSfuGCB 1thMYqlmgdhd9/BabGFbGGYHA6U4/T5zqU+f6xHy1SsAQZ1MSKlLwekBIT+4/cLRGqCHjnV0 q5H/T6a7t5mPkbzSrOLSo4puj+IToNjYyYIDBWzhlA19avOa+rvUjmHtD3sFN7cXWtkGoi8b uNcby4U= Organization: UCLA Computer Science Department Message-ID: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> Date: Mon, 5 Nov 2018 09:28:27 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------8A990272667E9ABD2F314306" Content-Language: en-US X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------8A990272667E9ABD2F314306 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable > The main block of this code looks identical to the BSD specific code > just underneath (#ifdef TIOCNOTTY), is there a reason we can=E2=80=99t = reuse > that? I don't see why not. Proposed patch attached; please give it a try as I=20 don't use macOS. --------------8A990272667E9ABD2F314306 Content-Type: text/x-patch; name="0001-Let-macOS-vfork-to-create-processes.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Let-macOS-vfork-to-create-processes.patch" >From c72e828018b68ed1ce1cad9205b6037f86112a28 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 5 Nov 2018 09:25:46 -0800 Subject: [PATCH] Let macOS vfork to create processes * src/process.c (create_process) [DARWIN_OS]: Use vfork, not fork. However, do not use setsid; instead, rely on TIOCSPGRP. Move SIGCHLD ignoring to its logical place next to the ignoring of other signals. --- src/process.c | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/process.c b/src/process.c index 6cda4f27ac..dd8beed117 100644 --- a/src/process.c +++ b/src/process.c @@ -2066,21 +2066,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) int volatile forkerr_volatile = forkerr; struct Lisp_Process *p_volatile = p; -#ifdef DARWIN_OS - /* Darwin doesn't let us run setsid after a vfork, so use fork when - necessary. Also, reset SIGCHLD handling after a vfork, as - apparently macOS can mistakenly deliver SIGCHLD to the child. */ - if (pty_flag) - pid = fork (); - else - { - pid = vfork (); - if (pid == 0) - signal (SIGCHLD, SIG_DFL); - } -#else pid = vfork (); -#endif current_dir = current_dir_volatile; lisp_pty_name = lisp_pty_name_volatile; @@ -2098,18 +2084,22 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) /* 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. */ + Do this even if !PTY_FLAG; see Bug#30762. + However, Darwin should not invoke setsid after vfork (see + Bug#33050 and Bug#33154), so rely TIOCNOTTY below instead. */ +# ifndef DARWIN_OS setsid (); +# endif /* Make the pty's terminal the controlling terminal. */ if (pty_flag && forkin >= 0) { -#ifdef TIOCSCTTY +# ifdef TIOCSCTTY /* We ignore the return value because faith@cs.unc.edu says that is necessary on Linux. */ ioctl (forkin, TIOCSCTTY, 0); -#endif +# endif } -#if defined (LDISC1) +# ifdef LDISC1 if (pty_flag && forkin >= 0) { struct termios t; @@ -2118,17 +2108,15 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) if (tcsetattr (forkin, TCSANOW, &t) < 0) emacs_perror ("create_process/tcsetattr LDISC1"); } -#else -#if defined (NTTYDISC) && defined (TIOCSETD) +# elif defined NTTYDISC && defined TIOCSETD if (pty_flag && forkin >= 0) { /* Use new line discipline. */ int ldisc = NTTYDISC; ioctl (forkin, TIOCSETD, &ldisc); } -#endif -#endif -#ifdef TIOCNOTTY +# endif +# ifdef TIOCNOTTY /* In 4.3BSD, the TIOCSPGRP bug has been fixed, and now you can do TIOCSPGRP only to the process's controlling tty. */ if (pty_flag) @@ -2142,9 +2130,9 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) emacs_close (j); } } -#endif /* TIOCNOTTY */ +# endif -#if !defined (DONT_REOPEN_PTY) +# ifndef DONT_REOPEN_PTY /*** There is a suggestion that this ought to be a conditional on TIOCSPGRP, or !defined TIOCSCTTY. Trying the latter gave the wrong results on Debian GNU/Linux 1.1; @@ -2168,14 +2156,14 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) } } -#endif /* not DONT_REOPEN_PTY */ +# endif -#ifdef SETUP_SLAVE_PTY +# ifdef SETUP_SLAVE_PTY if (pty_flag) { SETUP_SLAVE_PTY; } -#endif /* SETUP_SLAVE_PTY */ +# endif #endif /* HAVE_PTYS */ signal (SIGINT, SIG_DFL); @@ -2187,6 +2175,13 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) /* Emacs ignores SIGPIPE, but the child should not. */ signal (SIGPIPE, SIG_DFL); +#ifdef DARWIN_OS + /* https://lists.gnu.org/r/emacs-devel/2017-05/msg00342.html + says macOS has a bug where SIGCHLD is delivered to a vforked + child instead of to its parent. */ + signal (SIGCHLD, SIG_DFL); +#endif + /* Stop blocking SIGCHLD in the child. */ unblock_child_signal (&oldset); -- 2.19.1 --------------8A990272667E9ABD2F314306-- From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Filipp Gunbin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 06 Nov 2018 13:47:01 +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 To: Paul Eggert Cc: Alan Third , 33154@debbugs.gnu.org Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.154151197924995 (code B ref 33154); Tue, 06 Nov 2018 13:47:01 +0000 Received: (at 33154) by debbugs.gnu.org; 6 Nov 2018 13:46:19 +0000 Received: from localhost ([127.0.0.1]:36151 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gK1gQ-0006V5-HL for submit@debbugs.gnu.org; Tue, 06 Nov 2018 08:46:18 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:55133) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gK1gO-0006Un-Gv for 33154@debbugs.gnu.org; Tue, 06 Nov 2018 08:46:17 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 64A0FFD3; Tue, 6 Nov 2018 08:46:10 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 06 Nov 2018 08:46:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type:content-transfer-encoding; s=fm1; bh= JvnhMbaVKIFaDty6D1ssKwtxuIZz3d6OnmUZZ7/3Kek=; b=JarOPOpWnE5FY+Yt qHAu4JUBiCsbtPzqXsag6Tp7t0VXh2LGbY1WvLScvFAJ2PTPGf+r3Nw5g1qbd0hz iLOH7bjTmCAyQbSzJjnENvmn7fF4wrIWzwVzgByTWROMEftHeQRjzdK5dBs0d38w jFbLXIpQz2Z3U/CC2/0j3hqtaCDL5T05838oskurqX2jWigLC6vUFh3uUk0NUidM 7sg0g/d0x9CkpGG9HDMX/I5Y1L+uovMPtCG1H448C8P122AvYOW7fKMKOg8Zawg3 w/bss4oBcW0QgTG0S/rjczFDm8raqCKAjXGT1r7OTmUrcVlR0xb0ehnNTW8Gnr6o WnrkCA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=JvnhMbaVKIFaDty6D1ssKwtxuIZz3d6OnmUZZ7/3K ek=; b=nEHIGn72G5NAVc6sdagg1Yn5ODX5C742KKYcms6EnYORBvgxEKZXzQmL/ l67MwcubxFQGJR4WaJIodCEPL2JxOSj30TqOt0ubfCTIjbSEI5Mmdlu6ldJHJYtZ 7cYo7X3Ki9KptGjS3h/AJHgvZDEg8sFQnzaO7/HaPud7PS3NRZr0Z+T2NtVd+bFE jo32pVQu+xQvgbBJhyf/fS1oIOp7rfA70wDtVE7NxF57230f62lSliMLq1FZSF+8 YWOfwt/jt64gIseZqwt7nwSaxNNfYHehGvewG5tkXdco8OFiwmT/8X8DBDGusmvM qHYKj/oIBLbu7RMASYZhP/lqaXCGA== X-ME-Sender: X-ME-Proxy: Received: from fgunbin.playteam.ru (unknown [95.161.147.10]) by mail.messagingengine.com (Postfix) with ESMTPA id B558A102E0; Tue, 6 Nov 2018 08:46:08 -0500 (EST) From: Filipp Gunbin In-Reply-To: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> (Paul Eggert's message of "Mon, 5 Nov 2018 09:28:27 -0800") References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (darwin) Date: Tue, 06 Nov 2018 16:46:06 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 05/11/2018 09:28 -0800, Paul Eggert wrote: >> The main block of this code looks identical to the BSD specific code >> just underneath (#ifdef TIOCNOTTY), is there a reason we can=E2=80=99t r= euse >> that? > > I don't see why not. Proposed patch attached; please give it a try as > I don't use macOS. Paul, thanks for the patch. I'm seeing some problems with my fix - specifically, with sudo run as async shell command: "sudo: no tty present and no askpass program specified" and with tramp when trying to connect to anything via ssh: Permission denied, please try again. Permission denied, please try again. Received disconnect from port 22:2: Too many authentication failures Disconnected from port 22 I didn't have time to look into it. When I handle it, I'll try your patch also and will write back. Filipp From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Filipp Gunbin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Nov 2018 01:24:01 +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 To: Paul Eggert Cc: Alan Third , 33154@debbugs.gnu.org Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.15415538251548 (code B ref 33154); Wed, 07 Nov 2018 01:24:01 +0000 Received: (at 33154) by debbugs.gnu.org; 7 Nov 2018 01:23:45 +0000 Received: from localhost ([127.0.0.1]:37984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKCZN-0000Ou-JM for submit@debbugs.gnu.org; Tue, 06 Nov 2018 20:23:45 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:53745) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKCZM-0000Of-2A for 33154@debbugs.gnu.org; Tue, 06 Nov 2018 20:23:44 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 3CDD8E2E; Tue, 6 Nov 2018 20:23:38 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 06 Nov 2018 20:23:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=fm1; bh=0ilYPp+k/1YD//uQxrwnbWg5Hu K/m+hbPU1lU+gsMPM=; b=lVLOmH041FFAus0oIMSJXQHzfbG2VhPtpT7+iVdk9F 9wI4DzeTomDaBRUwQEMyik4CNI6h6DabO5YwcGtXh0NhBr/R48hauiJxSYK/3o2k 6vz33iyxUXJa01vD46kkOkIxp2QpjgHjLdrMXhK9NrAz1TdzcUbsxMcM2uOt4Koa XLnt1i4lpBit4uqaJjPDkvXCUX92M2MtQAbItgcwLFpoP2nsldRXdYwsUyrGC87b pankFUCBpEam2dPGET3VU+SI2/9uH9YE07hVBIhUMCwkZ+F9xFSGKVh2EESHVYeW PCScmLhAYX01vXw6s7MpHXpvS+znnbVIDRK4Lzs/3ebw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=0ilYPp +k/1YD//uQxrwnbWg5HuK/m+hbPU1lU+gsMPM=; b=pZeYfHwNVCZnXzxPW0l0+m 49tSTOAKR1CjTZVECa/h7oza/957qWT7NMNbW5I/USN/X+2qNK4J/QbiJGSoB+Kp cukeXOWEqSVfWh11wCRfTFF81c5BZR6NOieyhgnPiSnJdfrPXlUKwF0/yPfy6p2N mUJXTfot6+OmFWpOASoMUeCvh0sHjvv3q/P9SK3F+7FYh6SjHftQXlsEetxdYYQz nq1Nmq5AvdfPkCH/wk7u1LWYhJFfNUobiTMKo1PrDON9Hp+OFZK2DdY6Ix/NHQRe j1Vz+Y/IL9NgoXhmrHCScjDMEwRm8nnSqw7gTkRdVZgixnooG2Cj1JHS1Wor+azg == X-ME-Sender: X-ME-Proxy: Received: from fgunbin.local (unknown [93.185.27.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 32A12102ED; Tue, 6 Nov 2018 20:23:36 -0500 (EST) From: Filipp Gunbin In-Reply-To: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> (Paul Eggert's message of "Mon, 5 Nov 2018 09:28:27 -0800") References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (darwin) Date: Wed, 07 Nov 2018 04:23:34 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Paul, I think this won't work: man tty (4): TIOCSCTTY void Make the terminal the controlling terminal for the process (the process must not currently have a controlling terminal). In your patch, we don't detach from current (Emacs's) controlling terminal before doing TIOCSCTTY. I think what Alan meant as "reuse" was to extract the code into some function. Filipp From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Filipp Gunbin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Nov 2018 01:36: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 To: 33154@debbugs.gnu.org Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.15415545352628 (code B ref 33154); Wed, 07 Nov 2018 01:36:02 +0000 Received: (at 33154) by debbugs.gnu.org; 7 Nov 2018 01:35:35 +0000 Received: from localhost ([127.0.0.1]:37991 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKCko-0000gJ-N3 for submit@debbugs.gnu.org; Tue, 06 Nov 2018 20:35:34 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:41767) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKCkn-0000g6-5s for 33154@debbugs.gnu.org; Tue, 06 Nov 2018 20:35:33 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 4D962E93 for <33154@debbugs.gnu.org>; Tue, 6 Nov 2018 20:35:27 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 06 Nov 2018 20:35:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=fm1; bh=OIu9LMd+BljzkCF+YyRfXPKhrm jLByCqd9HkRdLOta4=; b=p7MmbziznYUwIPW040TCKCdJKKiGcGNVEf2gsqXJ6V OmrWiilhaCm+uKdYT0xjNR7ImmjMztuCxv5y8zz3KwyvTB2P15YTCT84F0wp4GpA RYtFKN5rpVt9461n1VDRW1qD69Zwk1YWY5CW43LZg9sUdR7Fvq1eX3mI9hnCsQpM 4lNy4+WkCRCgvUq1lyy/7D618uk5Bt6LUnNihmLERudIVc9KjPZbhAs+bj24M/1s MDsFC35Aj4MggDH9ZcJVnlpNLqRhH4oX4BrWXSYolHL1twBRBKBMSre0+uZ0SYdm I+wYiOsPXor4PJi7Swyjw3SgmrKXlL4jyRHdJjprfxfQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=OIu9LM d+BljzkCF+YyRfXPKhrmjLByCqd9HkRdLOta4=; b=kYFYHGXMH/DCxl7S4PxIPJ qOVlfqm1815OLpBGzl50iGtzOweElMBhiVvqlcoWI3268yNvtyIbY1YKNwbUvdrE rDUZDjOEKLhE4w8CE5uEU5IOIrejzKIW7QsVWZurBemkm0AT6hRSI2pTwXwkBWmp o3O23J8JmOX7R6gJZBCQBW78RcAYK+JRLwrIReRcZuJfY0TQzzvChzB6kxtVKjsV eAN4QpxbRWzTxSEFsb+JQ3MrQJOYx8RnXg4F7PfheJGmeij8OtO6xvjQrC3N4jPT Mm5q2C7j/Vr9pQcc4pf1SFsMq89PE0KBHFMJjgUCHUK9lqg5h/jTca4U8axuM64g == X-ME-Sender: X-ME-Proxy: Received: from fgunbin.local (unknown [93.185.27.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 17E42102DE for <33154@debbugs.gnu.org>; Tue, 6 Nov 2018 20:35:25 -0500 (EST) From: Filipp Gunbin In-Reply-To: <20181026111227.GA48441@breton.holly.idiocy.org> (Alan Third's message of "Fri, 26 Oct 2018 12:12:27 +0100") References: <20181026111227.GA48441@breton.holly.idiocy.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (darwin) Date: Wed, 07 Nov 2018 04:35:24 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) 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) { From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Nov 2018 07:42: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 To: Filipp Gunbin Cc: Alan Third , 33154@debbugs.gnu.org Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.15415765164676 (code B ref 33154); Wed, 07 Nov 2018 07:42:02 +0000 Received: (at 33154) by debbugs.gnu.org; 7 Nov 2018 07:41:56 +0000 Received: from localhost ([127.0.0.1]:38064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKITM-0001DM-18 for submit@debbugs.gnu.org; Wed, 07 Nov 2018 02:41:56 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:38100) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKITK-0001D6-1f for 33154@debbugs.gnu.org; Wed, 07 Nov 2018 02:41:54 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B88C11600A5; Tue, 6 Nov 2018 23:41:47 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id pag2SdarmWuo; Tue, 6 Nov 2018 23:41:46 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C14871600AB; Tue, 6 Nov 2018 23:41:46 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id PHgC5XKaZ1G1; Tue, 6 Nov 2018 23:41:46 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 919C11600A5; Tue, 6 Nov 2018 23:41:46 -0800 (PST) References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Tue, 6 Nov 2018 23:41:46 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------2943A0983D181D379495110C" Content-Language: en-US X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------2943A0983D181D379495110C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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. --------------2943A0983D181D379495110C Content-Type: text/x-patch; name="0001-Dissociate-controlling-tty-better-on-Darwin.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Dissociate-controlling-tty-better-on-Darwin.patch" >From cff3581f79d5eeb251fb683250bf48da3f68895a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 6 Nov 2018 23:30:26 -0800 Subject: [PATCH] Dissociate controlling tty better on Darwin * src/process.c (dissociate_controlling_tty): New function. (create_process): Use it to dissociate controlling tty if setsid fails, which happens on Darwin after a vfork (Bug#33154). Do this on all platforms, not just on Darwin, as a similar problem is plausible elsewhere. * src/callproc.c (call_process): Use the new function here, too, for consistency and to avoid duplicate code. --- src/callproc.c | 14 +------------- src/process.c | 40 ++++++++++++++++++++++------------------ src/process.h | 1 + 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/callproc.c b/src/callproc.c index a2cfd2e94d..9f47c79b81 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -643,19 +643,7 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd, #endif unblock_child_signal (&oldset); - -#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 + dissociate_controlling_tty (); /* Emacs ignores SIGPIPE, but the child should not. */ signal (SIGPIPE, SIG_DFL); diff --git a/src/process.c b/src/process.c index 6cda4f27ac..7e78e172d3 100644 --- a/src/process.c +++ b/src/process.c @@ -1949,6 +1949,26 @@ close_process_fd (int *fd_addr) } } +void +dissociate_controlling_tty (void) +{ + if (setsid () < 0) + { +#ifdef TIOCNOTTY + /* Needed on Darwin after vfork, since setsid fails in a vforked + child that has not execed. + I wonder: would just ioctl (fd, TIOCNOTTY, 0) work here, for + some fd that the caller already has? */ + int ttyfd = emacs_open (DEV_TTY, O_RDWR, 0); + if (0 <= ttyfd) + { + ioctl (ttyfd, TIOCNOTTY, 0); + emacs_close (ttyfd); + } +#endif + } +} + /* Indexes of file descriptors in open_fds. */ enum { @@ -2097,9 +2117,8 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) { /* 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. */ - setsid (); + dissociate_controlling_tty (); + /* Make the pty's terminal the controlling terminal. */ if (pty_flag && forkin >= 0) { @@ -2128,21 +2147,6 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) } #endif #endif -#ifdef TIOCNOTTY - /* In 4.3BSD, the TIOCSPGRP bug has been fixed, and now you - can do TIOCSPGRP only to the process's controlling tty. */ - if (pty_flag) - { - /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here? - I can't test it since I don't have 4.3. */ - int j = emacs_open (DEV_TTY, O_RDWR, 0); - if (j >= 0) - { - ioctl (j, TIOCNOTTY, 0); - emacs_close (j); - } - } -#endif /* TIOCNOTTY */ #if !defined (DONT_REOPEN_PTY) /*** There is a suggestion that this ought to be a diff --git a/src/process.h b/src/process.h index 3c6dd7b91f..67b783400d 100644 --- a/src/process.h +++ b/src/process.h @@ -300,6 +300,7 @@ extern Lisp_Object network_interface_info (Lisp_Object); extern Lisp_Object remove_slash_colon (Lisp_Object); extern void update_processes_for_thread_death (Lisp_Object); +extern void dissociate_controlling_tty (void); INLINE_HEADER_END -- 2.17.1 --------------2943A0983D181D379495110C-- From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Filipp Gunbin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Nov 2018 08:54:01 +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 To: Paul Eggert Cc: Alan Third , 33154@debbugs.gnu.org Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.154158081511599 (code B ref 33154); Wed, 07 Nov 2018 08:54:01 +0000 Received: (at 33154) by debbugs.gnu.org; 7 Nov 2018 08:53:35 +0000 Received: from localhost ([127.0.0.1]:38103 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKJag-000311-QL for submit@debbugs.gnu.org; Wed, 07 Nov 2018 03:53:34 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:41975) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKJae-00030o-Na for 33154@debbugs.gnu.org; Wed, 07 Nov 2018 03:53:33 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 030BF221BF; Wed, 7 Nov 2018 03:53:27 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 07 Nov 2018 03:53:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=fm1; bh=jpbBEPBwaUT+mychMWuJN7lZ2g T8fLXwv1pj+YAGs3Q=; b=U4tF4ie3bIUqz0mxpZ1UK1IDl+GSMLT19ZAyCKmDu0 buqcMwDlA91bJH9rhKNKaOlXssMqQl0eLL39fekT+wKe+Pgpn3xvet09boRblASG QbMtUNOy4R1y7wU+lYREAA8Gp1k979kJr+H9kO7WQJFnNllHCdainz0fxDwoFyHV y/uSxV+mWmVOUSFePG4J4wq1SRtwxbhFY8DgR8YEq9F8pxFYor4BdTFTu/wG2yMe 3v20qrgyXTOxwQkNRArgqaZ07kZwPHCEi+TLIa79zj3voV9GqYfi/XH1teGz6nLJ yWH5A5txIe/DlDhKox4/Q3N4xhu0sNE1wOlJ8wCFsbhA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=jpbBEP BwaUT+mychMWuJN7lZ2gT8fLXwv1pj+YAGs3Q=; b=Q2iYCFLx06kUymw2Zd1jfW exmD0n20Tj/cj1X++IZKfm+c5Ww+QjoSRhQsBb1IQScf/SryiHTXJTsTUhbQXUjt 2v7hhj07fevs+tHQU9jcLIPo3h6c3sge6CYV8tRV0cmrwr+09oOlpjQThDX6NfU9 SxAQIEcSlZpuma87/PFRxA4nGdW2gZ4xmPxkNat/nv5cehYDisBFP4mFyF7pWlKH SqVidjDxNWGt18/Rs0bJQ/mTHpR/Q4O+00pwO5AFvpxD1kqbCxI7sk1BUgvVtnWl O9fU30RpN8mAqh7rcROI+0Uc85XoMP0pcdCLrQibVe8wUWkbavWkRoxuJqmwx1UQ == X-ME-Sender: X-ME-Proxy: Received: from fgunbin.local (unknown [93.185.27.48]) by mail.messagingengine.com (Postfix) with ESMTPA id 7CB80102DE; Wed, 7 Nov 2018 03:53:25 -0500 (EST) From: Filipp Gunbin In-Reply-To: (Paul Eggert's message of "Tue, 6 Nov 2018 23:41:46 -0800") References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (darwin) Date: Wed, 07 Nov 2018 11:53:23 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Yes, dissociate_controlling_tty looks nice. I thought about checking what setsid() returns too, but thought I'd do this after some testing. > Also, I think we can call the function from just two places (not > three). Are you sure we can remove that 3rd place? It dates back to initial revision from 1992. And I can't tell why it's there and what it does. Filipp From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 Nov 2018 15:41: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 To: Filipp Gunbin Cc: Alan Third , 33154@debbugs.gnu.org Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.15416052502538 (code B ref 33154); Wed, 07 Nov 2018 15:41:02 +0000 Received: (at 33154) by debbugs.gnu.org; 7 Nov 2018 15:40:50 +0000 Received: from localhost ([127.0.0.1]:39747 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKPwo-0000er-0G for submit@debbugs.gnu.org; Wed, 07 Nov 2018 10:40:50 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:53776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gKPwm-0000ee-AD for 33154@debbugs.gnu.org; Wed, 07 Nov 2018 10:40:48 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 20B5016012E; Wed, 7 Nov 2018 07:40:42 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Ha6L0wXink7G; Wed, 7 Nov 2018 07:40:41 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 52D181600D0; Wed, 7 Nov 2018 07:40:41 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id vXTCR16PCmTT; Wed, 7 Nov 2018 07:40:41 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 2BF221600A5; Wed, 7 Nov 2018 07:40:41 -0800 (PST) References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <874fd659-2b77-4b8e-24f5-3296c28f6286@cs.ucla.edu> Date: Wed, 7 Nov 2018 07:40:36 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Filipp Gunbin wrote: > Are you sure we can remove that 3rd place? It dates back to initial > revision from 1992. And I can't tell why it's there and what it does. It's there to dissociate the controlling tty. And it's not removed, it's just moved into the previous call to dissociate_controlling_tty (when setsid fails). It is a little disconcerting to change code this old. But we needn't worry about how it would run on 4.3BSD, only on current platforms. On most current platforms setsid suffices because POSIX says it should; on Darwin (and perhaps a few other BSD-derived systems) Emacs can fall back on TIOCNOTTY when setsid fails; and the proposed code does this more systematically than the current master does. From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] 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 To: Paul Eggert Cc: 33154@debbugs.gnu.org, Filipp Gunbin Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.154172207324683 (code B ref 33154); Fri, 09 Nov 2018 00:08:02 +0000 Received: (at 33154) by debbugs.gnu.org; 9 Nov 2018 00:07:53 +0000 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 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 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) 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) Date: Fri, 9 Nov 2018 00:07:41 +0000 From: Alan Third Message-ID: <20181109000741.GA15142@breton.holly.idiocy.org> References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Score: 0.2 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) 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 From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Filipp Gunbin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Nov 2018 10:31: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 To: Alan Third Cc: Paul Eggert , 33154@debbugs.gnu.org Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.154175940925788 (code B ref 33154); Fri, 09 Nov 2018 10:31:02 +0000 Received: (at 33154) by debbugs.gnu.org; 9 Nov 2018 10:30:09 +0000 Received: from localhost ([127.0.0.1]:42253 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gL43E-0006hp-2z for submit@debbugs.gnu.org; Fri, 09 Nov 2018 05:30:09 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:45201) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gL43B-0006fy-L9 for 33154@debbugs.gnu.org; Fri, 09 Nov 2018 05:30:06 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 88697C4C; Fri, 9 Nov 2018 05:29:59 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Fri, 09 Nov 2018 05:29:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type:content-transfer-encoding; s=fm1; bh= rToZ36kCN8Ybk7TMwMkwBM6uSGDNSrA/OSEXl+t1IZo=; b=gpmc5fTOR02h9n3X WjHD8BSciSBjrtln2I6bz5OueGT3QfunzEsITJi89INpZAdh45744rf0eHp0PIBQ KhKdc04vxEs/zHFFcvye+5JZ4oAbuWOBSzJ57wDEMnT98g/fSaSkQDRDdJW7puOd 06X5iwZ4s3tFcAnm88eS+ZYiIXKrqfpPpjqHFpTIyDoVHJA0VHNn28kmzOd1eO6N 6CA7L/xkgYINyNZAqgJAyFA6jLxCxxOX1+3zvQy5QmvHesCYsmjvLMA4xE0cr00b NB4IV4hjQktC1ezI5E5x6YOf7iLu5DqtAN4gQaIRExpbyF/9tXOrO0uCke3InMBZ X1XKpw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=rToZ36kCN8Ybk7TMwMkwBM6uSGDNSrA/OSEXl+t1I Zo=; b=Vh1M+D9HSxWVI+XExYMLo1RJZhIebw48qWJSnfLGV/fpNfkiddfIDa4MI S9EdE28+qWz4e49z4W/azYePxcWZgexRHX8OHU5iJZrcNj9frpgMEJ52eQzo6Cmu IYvahZrbNCHOzHuouUD+EB6bNH3MIA8xRxj7NlkGAH2gqg+WVEka7JT/M8CCulhJ nzioTv3NrGodAPt+314y9lkw7DJi3mpfD2y2pA8VNQS0qm70eVmUXgzQsFXDkJNZ AdWEguGqhOiZd/L6WF/iAz3wG/Cjsk5aQyuxYbaP42Bm+flBpa6Hw/UrKWgGMfKP ikCYmicmGR7gysLBCvoLHmWex5+/g== X-ME-Sender: X-ME-Proxy: Received: from fgunbin.local (unknown [91.220.219.13]) by mail.messagingengine.com (Postfix) with ESMTPA id CCF3BE4619; Fri, 9 Nov 2018 05:29:57 -0500 (EST) From: Filipp Gunbin In-Reply-To: <20181109000741.GA15142@breton.holly.idiocy.org> (Alan Third's message of "Fri, 9 Nov 2018 00:07:41 +0000") References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> <20181109000741.GA15142@breton.holly.idiocy.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (darwin) Date: Fri, 09 Nov 2018 13:29:55 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) 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/c= lose >> fallback code, making three duplicates in all. How about if we coalesce >> these duplicates into a function and then call that function? Also, I th= ink >> 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 fallba= ck >> to open/TIOCNOTTY/close everywhere TIOCNOTTY is available), not just Dar= win. >> 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=E2=80=90x shell RET bg REST > > doesn=E2=80=99t report that there=E2=80=99s 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=E2=80=99d expect to s= ee. > > I=E2=80=99m not even sure if they=E2=80=99re really relevant, tbh. Is the= re 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 From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Andreas Schwab Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Nov 2018 11:17: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 To: Filipp Gunbin Cc: Alan Third , Paul Eggert , 33154@debbugs.gnu.org Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.154176220730213 (code B ref 33154); Fri, 09 Nov 2018 11:17:02 +0000 Received: (at 33154) by debbugs.gnu.org; 9 Nov 2018 11:16:47 +0000 Received: from localhost ([127.0.0.1]:42261 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gL4mM-0007rD-78 for submit@debbugs.gnu.org; Fri, 09 Nov 2018 06:16:47 -0500 Received: from mail-out.m-online.net ([212.18.0.10]:39622) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gL4mK-0007r4-A7 for 33154@debbugs.gnu.org; Fri, 09 Nov 2018 06:16:44 -0500 Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 42ryK630Ypz1qxKH; Fri, 9 Nov 2018 12:16:41 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 42ryK51kSXz1qsK0; Fri, 9 Nov 2018 12:16:41 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id bxoKJ6oE4L1X; Fri, 9 Nov 2018 12:16:40 +0100 (CET) X-Auth-Info: hbHp6qhSBvjywclvNtJNoi4WjAKzZMqUCogD9SrptR9ZDPsi9XA9uUK2o5SiexH+ Received: from igel.home (ppp-188-174-156-12.dynamic.mnet-online.de [188.174.156.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 9 Nov 2018 12:16:40 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id B27CC2C1085; Fri, 9 Nov 2018 12:16:39 +0100 (CET) From: Andreas Schwab References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> <20181109000741.GA15142@breton.holly.idiocy.org> X-Yow: I know how to get the hostesses released! Give them their own television series! Date: Fri, 09 Nov 2018 12:16:39 +0100 In-Reply-To: (Filipp Gunbin's message of "Fri, 09 Nov 2018 13:29:55 +0300") Message-ID: <875zx6cxgo.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On Nov 09 2018, Filipp Gunbin wrote: > I have one failing case: "M-x shell-command sudo ls -la" reports "sudo: > no tty present and no askpass program specified". That's not a bug. If shell-command runs the command synchronously it doesn't allocate a tty. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Filipp Gunbin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Nov 2018 15:25: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 To: Andreas Schwab Cc: Alan Third , Paul Eggert , 33154@debbugs.gnu.org Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.15418634916880 (code B ref 33154); Sat, 10 Nov 2018 15:25:02 +0000 Received: (at 33154) by debbugs.gnu.org; 10 Nov 2018 15:24:51 +0000 Received: from localhost ([127.0.0.1]:44887 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gLV7z-0001mt-11 for submit@debbugs.gnu.org; Sat, 10 Nov 2018 10:24:51 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:57703) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gLV7w-0001mh-K7 for 33154@debbugs.gnu.org; Sat, 10 Nov 2018 10:24:48 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 4C5EA22040; Sat, 10 Nov 2018 10:24:43 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sat, 10 Nov 2018 10:24:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=fm1; bh=ncgBu6CvQptzenaJdaHPZkD7wd 3kHhwSULqgQbjmZTk=; b=hAk71SP0kJhd3YOT2xQhRXcJHDB/5Kt8qXcndbXKT0 nC0uwe2S/iI3J/IB83PBqs6InthZVFcVwWf15Qi+/mOXMduSL12r1tdwcOlgu7Ve sw9m/U8GRfs/M/VKNNkksenvL4bbBfroXdPMWKxEkGuHGN5p/uGBER/z8c+tih77 fTjqf/MHuNfXbqSipIqkIJDhwniLpDe7Si4/uNnf+O6r1REZKicd/3tOyoIsUZe6 xLlGM3GqACabvxyRKtyhl6AZSDZJ/3IBiNonUiEC1yvN5/p1dsCXY/rr3kSbKiRL BKWUEAoNc72HxOk1Pcz7U7aQqWNQlUIq2jc8WhUXcscg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=ncgBu6 CvQptzenaJdaHPZkD7wd3kHhwSULqgQbjmZTk=; b=QOIS9DVi8AYvvPE82oV0iD KMcrHW+LbR1ViNU6lClAyOZQ0v2peHeh+OlcJAIB8pTaIDHuaR0ciZii2xcHKH++ q/RVgZOWfcLdiQFUN23oUT2u9xF1uwMvJ1mPXDlF8qEM7KOl1bzIJqdHtE6y+t4C +bASG6W1InA/SKuTLx4vyraUlGMKOSWtbxBs40cosgtIhJ41o9TLx0ISNOZ1Jb4x eqL3dUwAjN7v01Nh8pMH6nQOJHVKpxGsyFmNB933ZRaq+uqHQI3W+nDn7ehEvjlx ZSH5q9wuH6z942hR588Kr5cgNuzPyR9MD9Cwg7rCaou1vE71yjaL7iYJRY2bRrnQ == X-ME-Sender: X-ME-Proxy: Received: from fgunbin.local (unknown [89.20.134.23]) by mail.messagingengine.com (Postfix) with ESMTPA id ADCFFE4443; Sat, 10 Nov 2018 10:24:41 -0500 (EST) From: Filipp Gunbin In-Reply-To: <875zx6cxgo.fsf@igel.home> (Andreas Schwab's message of "Fri, 09 Nov 2018 12:16:39 +0100") References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> <20181109000741.GA15142@breton.holly.idiocy.org> <875zx6cxgo.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (darwin) Date: Sat, 10 Nov 2018 18:24:39 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 09/11/2018 12:16 +0100, Andreas Schwab wrote: > On Nov 09 2018, Filipp Gunbin wrote: > >> I have one failing case: "M-x shell-command sudo ls -la" reports "sudo: >> no tty present and no askpass program specified". > > That's not a bug. If shell-command runs the command synchronously it > doesn't allocate a tty. Are there any reasons for not allocating a pty in this case? A synchronous program may be interactive. From unknown Wed Sep 10 01:08:50 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Filipp Gunbin Subject: bug#33154: closed (Re: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH]) Message-ID: References: <46eebc4b-2c93-eeca-faa1-7fd041ed19ec@cs.ucla.edu> X-Gnu-PR-Message: they-closed 33154 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 33154@debbugs.gnu.org Date: Sat, 10 Nov 2018 17:06:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1541869563-16407-1" This is a multi-part message in MIME format... ------------=_1541869563-16407-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #33154: 27.0.50; create_process on Darwin should not invoke setsid() after = vfork() [PATCH] which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 33154@debbugs.gnu.org. --=20 33154: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D33154 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1541869563-16407-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 33154-done) by debbugs.gnu.org; 10 Nov 2018 17:05:33 +0000 Received: from localhost ([127.0.0.1]:44903 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gLWhR-0004Fv-9Z for submit@debbugs.gnu.org; Sat, 10 Nov 2018 12:05:33 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:40076) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gLWhP-0004Fi-Gh for 33154-done@debbugs.gnu.org; Sat, 10 Nov 2018 12:05:32 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id AEE0B1600A5; Sat, 10 Nov 2018 09:05:25 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 4SKi5ybsss8o; Sat, 10 Nov 2018 09:05:25 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 03BA1160092; Sat, 10 Nov 2018 09:05:25 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id xKZ9EYYQvqJA; Sat, 10 Nov 2018 09:05:24 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id BB0E9160079; Sat, 10 Nov 2018 09:05:24 -0800 (PST) Subject: Re: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] To: Alan Third References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> <20181109000741.GA15142@breton.holly.idiocy.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <46eebc4b-2c93-eeca-faa1-7fd041ed19ec@cs.ucla.edu> Date: Sat, 10 Nov 2018 09:05:24 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181109000741.GA15142@breton.holly.idiocy.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 33154-done Cc: Filipp Gunbin , 33154-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Alan Third wrote: > I only have two tests I know of to try here and they both pass Thanks for checking. I installed the patch on the master branch and am marking this bug as done. ------------=_1541869563-16407-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 25 Oct 2018 19:30:50 +0000 Received: from localhost ([127.0.0.1]:42832 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gFlLG-0005Te-Cv for submit@debbugs.gnu.org; Thu, 25 Oct 2018 15:30:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46963) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gFlLF-0005TR-7x for submit@debbugs.gnu.org; Thu, 25 Oct 2018 15:30:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFlL5-0001ub-54 for submit@debbugs.gnu.org; Thu, 25 Oct 2018 15:30:44 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_40,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33026) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFlL2-0001tR-8M for submit@debbugs.gnu.org; Thu, 25 Oct 2018 15:30:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFlL1-00033v-8y for bug-gnu-emacs@gnu.org; Thu, 25 Oct 2018 15:30:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFlKu-0001pp-EQ for bug-gnu-emacs@gnu.org; Thu, 25 Oct 2018 15:30:34 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:54483) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFlKj-0001iv-A9 for bug-gnu-emacs@gnu.org; Thu, 25 Oct 2018 15:30:19 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id AF5C13C5 for ; Thu, 25 Oct 2018 15:30:15 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 25 Oct 2018 15:30:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:subject:date:message-id:mime-version:content-type; s= fm1; bh=brwJnsGqjJ+XRzMuruEyCpehkA8feT+TSGRx9XmvTIo=; b=U0sE5elR khBGkLsRzZgVLNKilETLxG25RP4sulfA3+8014F50h6hImynCClRB7F9LXuHOgps gbgS0kCvLwT6C1kTBFKwc7wGjAZyWKy+Y6lbekN3CWXUXz4EqpA8xaLSo77VmiIF oOLvx6sCbm3wgou8Ra1ozChByAC8oMbzOjJcgoRUZ2IdH98seGTbV4Cw5I7P7qg8 AwOmjyck685xF4oXbkA+l2JaA9rPe63S2rKnL+cVcUmPlLeXoGUItqoGnJYAnEBj Irev4dHOt7O7fMlpm9J0yrkjrwo9PpnpzGGkwYyWLNrPcMrqa1IE1wf7KINmpc9q WKtb9bocRrwuUg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=brwJnsGqjJ+XRzMuruEyCpehkA8fe T+TSGRx9XmvTIo=; b=EGHsP9cbmDkl4liJg3lsl1h1cDoVRRfdCLh9/TM8G9ZG8 tEteX/6E4u7beZgdZx4UBn0bacP+i29j6XHgrmiA5dWJ7dllpMTAWVIJiLeFVQbe vgV4QSuFzTPhqM8PUjGT9vg+dxpRbz5niIlwkYlkPgcpWDEMxV260+Q5ymM1dBJo Pn1+HR8nknFhlduQg33XXuNhJb35lXuko77o8wofoYgQhf6b6Zw7qzBBpk5CtLJb mMUqPxdveFzUW33IbLu2yGTdAbMF/zOxGil+BXr/SSIHXUqwtU2jATcdT7YRvxHC nxIewUsZA54WR6vF5bJVkd1XKpKfcfzA4mCLPl9iA== X-ME-Sender: X-ME-Proxy: Received: from fgunbin.playteam.ru (unknown [95.161.147.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 93298102F2 for ; Thu, 25 Oct 2018 15:30:14 -0400 (EDT) From: Filipp Gunbin To: bug-gnu-emacs@gnu.org Subject: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Date: Thu, 25 Oct 2018 22:30:12 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.3 (-----) 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 Suggested patch is below. Thanks. In GNU Emacs 27.0.50 (build 12, x86_64-apple-darwin17.7.0, NS appkit-1561.60 Version 10.13.6 (Build 17G65)) of 2018-10-25 built on fgunbin.playteam.ru Repository revision: f1f1687fcd8d48cd519c0f2977bcecbf394a7f01 System Description: Mac OS X 10.13.6 diff --git a/src/process.c b/src/process.c index 6cda4f27ac..1f8810927d 100644 --- a/src/process.c +++ b/src/process.c @@ -2066,21 +2066,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) int volatile forkerr_volatile = forkerr; struct Lisp_Process *p_volatile = p; -#ifdef DARWIN_OS - /* Darwin doesn't let us run setsid after a vfork, so use fork when - necessary. Also, reset SIGCHLD handling after a vfork, as - apparently macOS can mistakenly deliver SIGCHLD to the child. */ - if (pty_flag) - pid = fork (); - else - { - pid = vfork (); - if (pid == 0) - signal (SIGCHLD, SIG_DFL); - } -#else pid = vfork (); -#endif current_dir = current_dir_volatile; lisp_pty_name = lisp_pty_name_volatile; @@ -2091,15 +2077,35 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) p = p_volatile; pty_flag = p->pty_flag; - if (pid == 0) #endif /* not WINDOWSNT */ { +#ifdef DARWIN_OS + /* Work around a macOS bug, where SIGCHLD is apparently + delivered to a vforked child instead of to its parent. See: + https://lists.gnu.org/r/emacs-devel/2017-05/msg00342.html + */ + signal (SIGCHLD, SIG_DFL); +#endif + /* 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 /* Make the pty's terminal the controlling terminal. */ if (pty_flag && forkin >= 0) { ------------=_1541869563-16407-1-- From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 10 Nov 2018 17:10: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 To: Filipp Gunbin , Andreas Schwab Cc: Alan Third , 33154@debbugs.gnu.org Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.154186976416798 (code B ref 33154); Sat, 10 Nov 2018 17:10:02 +0000 Received: (at 33154) by debbugs.gnu.org; 10 Nov 2018 17:09:24 +0000 Received: from localhost ([127.0.0.1]:44915 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gLWlA-0004Mr-2M for submit@debbugs.gnu.org; Sat, 10 Nov 2018 12:09:24 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:40524) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gLWl7-0004Mb-1G for 33154@debbugs.gnu.org; Sat, 10 Nov 2018 12:09:21 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BC6C8160079; Sat, 10 Nov 2018 09:09:15 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id hAjAhWHVu5-8; Sat, 10 Nov 2018 09:09:15 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E7494160099; Sat, 10 Nov 2018 09:09:14 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 65d0xp69hGcU; Sat, 10 Nov 2018 09:09:14 -0800 (PST) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id B3D78160079; Sat, 10 Nov 2018 09:09:14 -0800 (PST) References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> <20181109000741.GA15142@breton.holly.idiocy.org> <875zx6cxgo.fsf@igel.home> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <214f349a-d95d-823a-3461-6facd9cbfbbf@cs.ucla.edu> Date: Sat, 10 Nov 2018 09:09:14 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Filipp Gunbin wrote: > On 09/11/2018 12:16 +0100, Andreas Schwab wrote: > >> On Nov 09 2018, Filipp Gunbin wrote: >> >>> I have one failing case: "M-x shell-command sudo ls -la" reports "sudo: >>> no tty present and no askpass program specified". >> >> That's not a bug. If shell-command runs the command synchronously it >> doesn't allocate a tty. > > Are there any reasons for not allocating a pty in this case? A > synchronous program may be interactive. How would the interaction work, though? I can see potential problems with existing Lisp code that runs synchronous commands if we allocate ptys for them. At any rate, that case has always failed the same way on Ubuntu 18.04 etc., so if this is a problem it's not limited to macOS and someone should file a new bug report for it. From unknown Wed Sep 10 01:08:50 2025 X-Loop: help-debbugs@gnu.org Subject: bug#33154: 27.0.50; create_process on Darwin should not invoke setsid() after vfork() [PATCH] Resent-From: Filipp Gunbin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 11 Nov 2018 17:15: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 To: Paul Eggert Cc: Alan Third , 33154@debbugs.gnu.org, Andreas Schwab Received: via spool by 33154-submit@debbugs.gnu.org id=B33154.154195648321014 (code B ref 33154); Sun, 11 Nov 2018 17:15:02 +0000 Received: (at 33154) by debbugs.gnu.org; 11 Nov 2018 17:14:43 +0000 Received: from localhost ([127.0.0.1]:46662 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gLtJr-0005Ss-GF for submit@debbugs.gnu.org; Sun, 11 Nov 2018 12:14:43 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:34427) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gLtJq-0005Sc-4l for 33154@debbugs.gnu.org; Sun, 11 Nov 2018 12:14:42 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id C2E1620E73; Sun, 11 Nov 2018 12:14:36 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 11 Nov 2018 12:14:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-type; s=fm1; bh=k4GczFtbSIPLElTsY0u2HNzTCb 2JMCA77fz+51V6vLU=; b=fHyJn0i5+0+v8b90grP1+DfGjPGwVxqHwSSCaI68k3 BEu00GVRUVogXgE+PNBt5zp0BFE9AFPnNZzcHZleRhQRPbpEjG8p9zommp2k+txm k9DLrCULX1qfsoUsJHmFAMSTqfwCdnXqvr3Z5XIvU4ju3Sh81mhyexmYZL22kKK7 uRX++G1A3K3osEx9WbA0FfeATKSJdf8/X9VpAbTvJtw7OEXLxAHA11iTcB/upqAd yfT4rzqUvYQSOAaJ1DgNm6MB94NPFdkH3Z8TyELFFaFwdc7OADShkjVNoonXR7tH LMicU7YmEjqfSzXfEZzUCA/JQccxc3/zPoVsZaaf5Xpg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=k4GczF tbSIPLElTsY0u2HNzTCb2JMCA77fz+51V6vLU=; b=SqAB3U4wf8n1EsgizuLinO +zJi8Kh9QcoQm3hdqRUB22zGCprgc1Y4hgtS7SSFb2CR7065Jw5+hJY8LfducJJR /E1Zon64b6cwveHXz9Xc0vnrtndDowJYCuEAokdYWEgDEaCKi+edojagW1z7JF88 QX5yUxcxr/oqAgN7ZapOzCMWpe+bRtKtDJ4+8jZNnBDIb7U/YGQaP8w94CzQlFEA iPi4lj4qxUvVW/Ai/fAwlQZS+D+O/3qK1SZf2fIDVHB4Bq1+tG9YsOM0ht4vVhEW SSp0GAG7RzMV2YTipMsr38rjzRUtwA94mg6HZw3V5IcdlqrDvA+QmAZLEudNqp+Q == X-ME-Sender: X-ME-Proxy: Received: from fgunbin.local (unknown [93.185.19.97]) by mail.messagingengine.com (Postfix) with ESMTPA id 2D48B102F0; Sun, 11 Nov 2018 12:14:35 -0500 (EST) From: Filipp Gunbin In-Reply-To: <214f349a-d95d-823a-3461-6facd9cbfbbf@cs.ucla.edu> (Paul Eggert's message of "Sat, 10 Nov 2018 09:09:14 -0800") References: <8237cee2-9e65-4093-8077-a458cf58c911@cs.ucla.edu> <20181109000741.GA15142@breton.holly.idiocy.org> <875zx6cxgo.fsf@igel.home> <214f349a-d95d-823a-3461-6facd9cbfbbf@cs.ucla.edu> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (darwin) Date: Sun, 11 Nov 2018 20:14:33 +0300 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 10/11/2018 09:09 -0800, Paul Eggert wrote: > Filipp Gunbin wrote: >> On 09/11/2018 12:16 +0100, Andreas Schwab wrote: >> >>> On Nov 09 2018, Filipp Gunbin wrote: >>> >>>> I have one failing case: "M-x shell-command sudo ls -la" reports "sudo: >>>> no tty present and no askpass program specified". >>> >>> That's not a bug. If shell-command runs the command synchronously it >>> doesn't allocate a tty. >> >> Are there any reasons for not allocating a pty in this case? A >> synchronous program may be interactive. > > How would the interaction work, though? I can see potential problems with > existing Lisp code that runs synchronous commands if we allocate ptys > for them. Yes, I see, there's no way to interact. Without interaction, there's no sense in allocating pty. > At any rate, that case has always failed the same way on Ubuntu 18.04 etc., so > if this is a problem it's not limited to macOS and someone should file a new bug > report for it. No need for that. Thanks.