From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#14803: Setting close-on-exec flag consistently Date: Sat, 06 Jul 2013 14:43:26 -0700 Organization: UCLA Computer Science Department Message-ID: <51D88F7E.3080502@cs.ucla.edu> References: <51D7DFAF.3030500@cs.ucla.edu> <83obafylf1.fsf@gnu.org> <51D8514F.8090307@cs.ucla.edu> <834nc7y3o2.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1373147048 7505 80.91.229.3 (6 Jul 2013 21:44:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 6 Jul 2013 21:44:08 +0000 (UTC) Cc: 14803@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 06 23:44:08 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 1UvaH2-0006AI-9u for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Jul 2013 23:44:08 +0200 Original-Received: from localhost ([::1]:33665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvaH1-0004Xc-VS for geb-bug-gnu-emacs@m.gmane.org; Sat, 06 Jul 2013 17:44:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvaGx-0004XS-U3 for bug-gnu-emacs@gnu.org; Sat, 06 Jul 2013 17:44:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UvaGw-000561-Ux for bug-gnu-emacs@gnu.org; Sat, 06 Jul 2013 17:44:03 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvaGw-00055j-Ry for bug-gnu-emacs@gnu.org; Sat, 06 Jul 2013 17:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1UvaGw-0006yw-D8 for bug-gnu-emacs@gnu.org; Sat, 06 Jul 2013 17:44:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 06 Jul 2013 21:44: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.137314701726766 (code B ref 14803); Sat, 06 Jul 2013 21:44:02 +0000 Original-Received: (at 14803) by debbugs.gnu.org; 6 Jul 2013 21:43:37 +0000 Original-Received: from localhost ([127.0.0.1]:35550 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UvaGX-0006xe-3o for submit@debbugs.gnu.org; Sat, 06 Jul 2013 17:43:37 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:52913) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UvaGU-0006xG-VR for 14803@debbugs.gnu.org; Sat, 06 Jul 2013 17:43:35 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 214FCA60047; Sat, 6 Jul 2013 14:43:29 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M195OMTr2j6i; Sat, 6 Jul 2013 14:43:26 -0700 (PDT) Original-Received: from [192.168.1.9] (pool-71-108-49-126.lsanca.fios.verizon.net [71.108.49.126]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id D45F6A60001; Sat, 6 Jul 2013 14:43:26 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 In-Reply-To: <834nc7y3o2.fsf@gnu.org> X-Enigmail-Version: 1.5.1 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:76026 Archived-At: On 07/06/2013 10:54 AM, Eli Zaretskii wrote: >> Date: Sat, 06 Jul 2013 10:18:07 -0700 >> From: Paul Eggert >> On systems like w32 that lack SOCK_CLOEXEC, the code creates >> sockets just as it did before (using plain 'socket' and 'accept' >> rather than 'socket' and 'accept4' with SOCK_CLOEXEC). > > Given that w32 redirects calls to 'socket' to 'sys_socket', which is > implemented on w32.c, will the above still work? Yes, the idea is that it does the same calls as before, to the same code in w32.c as before. > I assume that lib/fcntl.c and > lib/pipe2.c will not be compiled for w32, due to some configure test? Yes, though that needs to be arranged. The following further patch should do it: === modified file 'ChangeLog' --- ChangeLog 2013-07-06 09:44:23 +0000 +++ ChangeLog 2013-07-06 21:39:31 +0000 @@ -1,7 +1,9 @@ 2013-07-06 Paul Eggert Make file descriptors close-on-exec when possible (Bug#14803). - * configure.ac (mkostemp): New function to check for. + * configure.ac (ac_cv_func_fcntl, gl_cv_func_fcntl_f_dupfd_cloexec) + (gl_cv_func_fcntl_f_dupfd_works, ac_cv_func_pipe2): Hotwire for MinGW. + (mkostemp): New function to check for. (PTY_OPEN): Pass O_CLOEXEC to posix_openpt. * lib/fcntl.c, lib/getdtablesize.c, lib/pipe2.c, m4/fcntl.m4: * m4/getdtablesize.m4, m4/pipe2.m4: New files, taken from gnulib. === modified file 'configure.ac' --- configure.ac 2013-07-06 07:04:07 +0000 +++ configure.ac 2013-07-06 21:33:56 +0000 @@ -634,6 +634,19 @@ # Avoid gnulib's threadlib module, as we do threads our own way. AC_DEFUN([gl_THREADLIB]) +# On MinGW, Emacs supplies its own substitutes for some missing functions, +# so hotwire the cache to pretend to Gnulib that the functions work; +# that way, 'configure' won't arrange to build the Gnulib substitutes. +if test "$opsys" = mingw32; then + # fcntl + ac_cv_func_fcntl=emulated # Any single word other than 'no' will do. + gl_cv_func_fcntl_f_dupfd_cloexec=yes # Actually 'no', but only 'yes' works. + gl_cv_func_fcntl_f_dupfd_works='no, but Emacs emulates yes' + + # pipe2 + ac_cv_func_pipe2='no, but Emacs emulates yes' +fi + # Initialize gnulib right after choosing the compiler. dnl Amongst other things, this sets AR and ARFLAGS. gl_EARLY