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#12881: Assume at least POSIX.1-1988 for fcntl.h Date: Wed, 14 Nov 2012 19:33:45 +0200 Message-ID: <83y5i4t7gm.fsf@gnu.org> References: <50A34A56.9080007@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1352914481 15856 80.91.229.3 (14 Nov 2012 17:34:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 Nov 2012 17:34:41 +0000 (UTC) Cc: 12881@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 14 18:34:51 2012 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 1TYgrM-0000Br-3l for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Nov 2012 18:34:44 +0100 Original-Received: from localhost ([::1]:45250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYgrC-0006iu-BX for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Nov 2012 12:34:34 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYgr6-0006ii-Tc for bug-gnu-emacs@gnu.org; Wed, 14 Nov 2012 12:34:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TYgr3-00041y-Qh for bug-gnu-emacs@gnu.org; Wed, 14 Nov 2012 12:34:28 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60436) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYgr3-00041u-NX for bug-gnu-emacs@gnu.org; Wed, 14 Nov 2012 12:34:25 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TYgrd-0000lF-KP for bug-gnu-emacs@gnu.org; Wed, 14 Nov 2012 12:35:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 14 Nov 2012 17:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12881 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13529144782893 (code B ref -1); Wed, 14 Nov 2012 17:35:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 14 Nov 2012 17:34:38 +0000 Original-Received: from localhost ([127.0.0.1]:42454 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TYgrF-0000kc-Rx for submit@debbugs.gnu.org; Wed, 14 Nov 2012 12:34:38 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:39339) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TYgrB-0000kS-SJ for submit@debbugs.gnu.org; Wed, 14 Nov 2012 12:34:35 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TYgqY-0003vD-Bu for submit@debbugs.gnu.org; Wed, 14 Nov 2012 12:33:57 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:54823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYgqY-0003v9-8v for submit@debbugs.gnu.org; Wed, 14 Nov 2012 12:33:54 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57091) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYgqV-0006fn-6M for bug-gnu-emacs@gnu.org; Wed, 14 Nov 2012 12:33:54 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TYgqS-0003q0-3f for bug-gnu-emacs@gnu.org; Wed, 14 Nov 2012 12:33:51 -0500 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:37948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYgqR-0003mp-RR for bug-gnu-emacs@gnu.org; Wed, 14 Nov 2012 12:33:48 -0500 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0MDH00800NAS1B00@a-mtaout22.012.net.il> for bug-gnu-emacs@gnu.org; Wed, 14 Nov 2012 19:33:24 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MDH007GYNFOJ590@a-mtaout22.012.net.il>; Wed, 14 Nov 2012 19:33:24 +0200 (IST) In-reply-to: <50A34A56.9080007@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: -4.4 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-Spam-Score: -4.4 (----) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.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:66924 Archived-At: > Date: Tue, 13 Nov 2012 23:37:58 -0800 > From: Paul Eggert > CC: Eli Zaretskii > > On POSIXish hosts it's long been safe to assume at least > POSIX.1-1988, as the pre-POSIX platforms died out long ago. > Attached is a patch to simplify Emacs to assume this > for . I haven't tested this on Windows but have > tried to make the Windows port work by renaming its O_NDELAY > flag to O_NONBLOCK, as POSIX standardized the spelling of this > flag to be O_NONBLOCK. I'll CC: this patch to Eli to give > him a heads-up. This patch is relative to trunk bzr 110892. Renaming O_NDELAY is a no-brainer, but the patch does much more than just that. In several places, it actually changes the code involved in dealing with the related issues. Here's one example: > @@ -4847,23 +4795,8 @@ > else if (nread == -1 && errno == EWOULDBLOCK) > ; > #endif > - /* ISC 4.1 defines both EWOULDBLOCK and O_NONBLOCK, > - and Emacs uses O_NONBLOCK, so what we get is EAGAIN. */ > -#if O_NONBLOCK > - else if (nread == -1 && errno == EAGAIN) > - ; > -#else > -#if O_NDELAY > - else if (nread == -1 && errno == EAGAIN) > - ; > - /* Note that we cannot distinguish between no input > - available now and a closed pipe. > - With luck, a closed pipe will be accompanied by > - subprocess termination and SIGCHLD. */ > - else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)) > - ; > -#endif /* O_NDELAY */ > -#endif /* O_NONBLOCK */ > + else if (nread == -1 && errno == EAGAIN) > + ; Here, the code that was left is identical to the one used by platforms with O_NONBLOCK, but the code used by platforms with O_NDELAY was different in non-trivial ways. Another potential problem is that the Windows emulation of fcntl only works for sockets, whereas O_NONBLOCK is now used in other system calls, like in emacs_open etc. This patch also modifies code unrelated to O_NONBLOCK, like this one: > --- src/callproc.c 2012-11-14 04:55:41 +0000 > +++ src/callproc.c 2012-11-14 07:26:25 +0000 > @@ -1317,16 +1317,7 @@ > return fd; > else > { > - int new; > -#ifdef F_DUPFD > - new = fcntl (fd, F_DUPFD, minfd); > -#else > - new = dup (fd); > - if (new != -1) > - /* Note that we hold the original FD open while we recurse, > - to guarantee we'll get a new FD if we need it. */ > - new = relocate_fd (new, minfd); > -#endif > + int new = fcntl (fd, F_DUPFD, minfd); > if (new == -1) > { > const char *message_1 = "Error while setting up child: "; Likewise with O_NOCTTY. It's possible that you've already analyzed all these places, and they either aren't getting compiled on Windows or are no-ops. If so, please tell the details. Failing that, Someone(TM) will have to do the footwork of making sure these changes don't break non-Posix platforms.