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: Fri, 16 Nov 2012 11:49:51 +0200 Message-ID: <83mwyhswqo.fsf@gnu.org> References: <50A34A56.9080007@cs.ucla.edu> <83y5i4t7gm.fsf@gnu.org> <50A48C67.7020603@cs.ucla.edu> <83ip96u5ic.fsf@gnu.org> <50A54B89.2080505@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1353059491 25798 80.91.229.3 (16 Nov 2012 09:51:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 16 Nov 2012 09:51:31 +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 Fri Nov 16 10:51:41 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 1TZIaF-0004dX-7F for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Nov 2012 10:51:35 +0100 Original-Received: from localhost ([::1]:55476 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZIa5-0003x8-7n for geb-bug-gnu-emacs@m.gmane.org; Fri, 16 Nov 2012 04:51:25 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44599) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZIZz-0003wt-Ug for bug-gnu-emacs@gnu.org; Fri, 16 Nov 2012 04:51:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TZIZw-0003pa-SX for bug-gnu-emacs@gnu.org; Fri, 16 Nov 2012 04:51:19 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36858) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TZIZw-0003pW-Ok for bug-gnu-emacs@gnu.org; Fri, 16 Nov 2012 04:51:16 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TZIag-0003Jt-5C for bug-gnu-emacs@gnu.org; Fri, 16 Nov 2012 04:52:02 -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: Fri, 16 Nov 2012 09:52:02 +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 Original-Received: via spool by 12881-submit@debbugs.gnu.org id=B12881.135305947612708 (code B ref 12881); Fri, 16 Nov 2012 09:52:02 +0000 Original-Received: (at 12881) by debbugs.gnu.org; 16 Nov 2012 09:51:16 +0000 Original-Received: from localhost ([127.0.0.1]:47109 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TZIZu-0003Iu-T3 for submit@debbugs.gnu.org; Fri, 16 Nov 2012 04:51:16 -0500 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:52840) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TZIZr-0003Ig-7I for 12881@debbugs.gnu.org; Fri, 16 Nov 2012 04:51:12 -0500 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0MDK00B00R912000@a-mtaout20.012.net.il> for 12881@debbugs.gnu.org; Fri, 16 Nov 2012 11:50:23 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MDK00A13RBZHKC0@a-mtaout20.012.net.il>; Fri, 16 Nov 2012 11:50:23 +0200 (IST) In-reply-to: <50A54B89.2080505@cs.ucla.edu> X-012-Sender: halo1@inter.net.il X-Spam-Score: 1.5 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-Spam-Score: -1.2 (-) 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:66984 Archived-At: > Date: Thu, 15 Nov 2012 12:07:37 -0800 > From: Paul Eggert > CC: 12881@debbugs.gnu.org > > On 11/15/12 09:42, Eli Zaretskii wrote: > > Thanks, please hold on to it for a few days, until I or someone else > > will have time to study it more closely. > > I'll hold onto it for a bit, but there's no need for a close review > process here. The code works fine on POSIXish hosts and we've done a > quick scan for plausible failures on Windows hosts and have come up > dry. Any problems that come up on Windows will likely be either > easy-to-fix compilation issues, or further simplifications of the code > that will not fix bugs. Thanks for waiting. The reason I prefer to review the patches such as this one is to minimize downtime for several Windows users who track the development trunk. As you see below, our initial discussion notwithstanding, your patches still break the Windows build in several places. Experience shows that if the Windows build is broken, it remains broken until I get to fix it, with no one else stepping forward to do that. It is IMO bad mojo for several good people to depend on my scarce free time or sleeping hours. Here's the result of reviewing the combined patch you've posted in http://debbugs.gnu.org/cgi/bugreport.cgi?bug=12881#20: @@ -4847,23 +4795,16 @@ 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) - ; + else if (nread == -1 && errno == EAGAIN) + ; +#ifdef DOS_NT /* 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 */ +#endif This hunk from process.c patches should use WINDOWSNT, not DOS_NT, since MSDOS does not compile that part of process.c. @@ -1278,8 +1276,7 @@ fsync (fileno (tty_out->output)); #endif -#ifdef F_SETFL -#ifdef F_SETOWN /* F_SETFL does not imply existence of F_SETOWN */ +#ifdef F_SETOWN if (interrupt_input) { reset_sigio (fileno (tty_out->input)); @@ -1287,11 +1284,8 @@ old_fcntl_owner[fileno (tty_out->input)]); } #endif /* F_SETOWN */ -#if O_NDELAY fcntl (fileno (tty_out->input), F_SETFL, - fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NDELAY); -#endif -#endif /* F_SETFL */ + fcntl (fileno (tty_out->input), F_GETFL, 0) & ~O_NONBLOCK); if (tty_out->old_tty) while (emacs_set_tty (fileno (tty_out->input), In this hunk, the block that was conditioned on F_SETFL should now be conditioned on !DOS_NT. The reason is that, although the Windows build does have F_SETFL defined, it is defined in sys/socket.h, which is not included by sysdep.c in the MS-Windows build. So this block of code was never compiled on Windows, and should continue not being compiled there, since it invokes fcntl on TTY handles, something that's not supported by w32.c:fcntl emulation, and also uses F_GETFL which is not defined on Windows. --- src/term.c 2012-11-14 04:55:41 +0000 +++ src/term.c 2012-11-14 07:26:25 +0000 @@ -55,14 +55,6 @@ #include "xterm.h" #endif -#ifndef O_RDWR -#define O_RDWR 2 -#endif - -#ifndef O_NOCTTY -#define O_NOCTTY 0 -#endif - /* The name of the default console device. */ #ifdef WINDOWSNT This hunk will break MS-Windows compilation because O_NOCTTY is no longer defined. I suggest adding the definition in the WINDOWSNT block just below, where the default console device name is defined. Also, you need to include fcntl.h in term.c, to get both O_RDRW and O_NOCTTY actually defined. I wonder how it compiled for you; presumably some other header on your platform includes fcntl.h internally, but we shouldn't depend on that, IMO. With those changes, I think the patch is safe to go into the trunk. Thanks.