From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#14803: Setting close-on-exec flag consistently Date: Sat, 06 Jul 2013 14:31:30 +0300 Message-ID: <83obafylf1.fsf@gnu.org> References: <51D7DFAF.3030500@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1373110389 7925 80.91.229.3 (6 Jul 2013 11:33:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Jul 2013 11:33:09 +0000 (UTC) Cc: 14803@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 06 13:33:09 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UvQjj-00049o-Je for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Jul 2013 13:33:07 +0200 Original-Received: from localhost ([::1]:45742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvQjj-0002H7-2d for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Jul 2013 07:33:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53534) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvQjg-0002FZ-Az for bug-gnu-emacs@gnu.org; Sat, 06 Jul 2013 07:33:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UvQjf-0004Aa-H0 for bug-gnu-emacs@gnu.org; Sat, 06 Jul 2013 07:33:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:39499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvQjf-0004AV-EX for bug-gnu-emacs@gnu.org; Sat, 06 Jul 2013 07:33:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1UvQje-0001Gi-Gu for bug-gnu-emacs@gnu.org; Sat, 06 Jul 2013 07:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Jul 2013 11:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14803 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 14803-submit@debbugs.gnu.org id=B14803.13731103394745 (code B ref 14803); Sat, 06 Jul 2013 11:33:02 +0000 Original-Received: (at 14803) by debbugs.gnu.org; 6 Jul 2013 11:32:19 +0000 Original-Received: from localhost ([127.0.0.1]:33813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UvQiw-0001EQ-Rh for submit@debbugs.gnu.org; Sat, 06 Jul 2013 07:32:19 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:42599) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UvQis-0001Du-NC for 14803@debbugs.gnu.org; Sat, 06 Jul 2013 07:32:16 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0MPI00G00IM96I00@a-mtaout22.012.net.il> for 14803@debbugs.gnu.org; Sat, 06 Jul 2013 14:31:32 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MPI00F7PIOKLZ80@a-mtaout22.012.net.il>; Sat, 06 Jul 2013 14:31:32 +0300 (IDT) In-reply-to: <51D7DFAF.3030500@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:75989 Archived-At: > Date: Sat, 06 Jul 2013 02:13:19 -0700 > From: Paul Eggert > > Tags: patch > > Here's a patch I'd like to install into Emacs soon. > It changes Emacs so that it creates file descriptors > that are close-on-exec unless they are intended to > be propagated to child processes. > This patch may affect the Microsoft Windows ports > so I'm sending it to bug-gnu-emacs first. > Much of the new code is imported from gnulib. Sorry, this won't fly. The Windows build has its own implementations of 'pipe' and 'socket' (because it needs to make them behave like Posix APIs, and also because it needs to watch each subprocess and each socket for the benefit of 'select', 'waitpid', SIGCHLD, etc.). So the replacements from gnulib won't do. Looking at the Emacs sources, I see that the Windows implementation of 'pipe' already makes it non-inheritable (see sys_pipe), so this problem does not exist in the Windows build. Socket handles _are_ inherited, but making them non-inheritable is not easy (some say impossible in the general case), and since no one complained till now, I'm willing to live with that until we hear some real problems. For mktemp/mkstemp in filelock.c, sys_open in w32.c already makes all handles not inheritable by default, so that problem doesn't exist, either. As for emacs_open, it needs to use O_NOINHERIT instead of O_CLOEXEC (or just use zero, since w32.c already adds the O_NOINHERIT flag in sys_open). So I think we should simply not compile lib/fcntl.c and lib/pipe2.c (including their dependency modules) on MS-Windows.