From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Jan_Dj=E4rv?= Newsgroups: gmane.emacs.devel Subject: Re: ^D is broken in shell-mode Date: Wed, 09 Jun 2010 08:28:23 +0200 Message-ID: <4C0F3487.101@swipnet.se> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1276067698 5261 80.91.229.12 (9 Jun 2010 07:14:58 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 9 Jun 2010 07:14:58 +0000 (UTC) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 09 09:14:57 2010 connect(): No such file or directory Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OMFV2-00040D-QN for ged-emacs-devel@m.gmane.org; Wed, 09 Jun 2010 09:14:57 +0200 Original-Received: from localhost ([127.0.0.1]:37353 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMFBZ-00077X-W3 for ged-emacs-devel@m.gmane.org; Wed, 09 Jun 2010 02:54:50 -0400 Original-Received: from [140.186.70.92] (port=39551 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMF1w-0002WL-PE for emacs-devel@gnu.org; Wed, 09 Jun 2010 02:44:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OMEm4-0008Uy-1c for emacs-devel@gnu.org; Wed, 09 Jun 2010 02:28:33 -0400 Original-Received: from smtprelay-b12.telenor.se ([62.127.194.21]:46882) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OMEm3-0008UQ-M0 for emacs-devel@gnu.org; Wed, 09 Jun 2010 02:28:28 -0400 Original-Received: from ipb3.telenor.se (ipb3.telenor.se [195.54.127.166]) by smtprelay-b12.telenor.se (Postfix) with ESMTP id 6F499D516 for ; Wed, 9 Jun 2010 08:28:24 +0200 (CEST) X-SENDER-IP: [85.225.45.35] X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Aj03AIrRDkxV4S0jPGdsb2JhbACHcJZTDAEBAQE1Lb0nhRYEg2c X-IronPort-AV: E=Sophos;i="4.53,389,1272837600"; d="scan'208";a="531729372" Original-Received: from c-232de155.25-1-64736c10.cust.bredbandsbolaget.se (HELO coolsville.localdomain) ([85.225.45.35]) by ipb3.telenor.se with ESMTP; 09 Jun 2010 08:28:24 +0200 Original-Received: from [172.20.199.2] (gaffa [172.20.199.2]) by coolsville.localdomain (Postfix) with ESMTP id 38F187FA05A; Wed, 9 Jun 2010 08:28:23 +0200 (CEST) User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:125658 Archived-At: 2010-06-08 22:22, Stefan Monnier skrev: >> It now results in a literal ^D being seen by the subproces. >> I vaguely recall seeing recently that emacs stopped using ICANON mode >> for ptys; I presume this is the cause? > > Yes. > >> It's been a long time since I did pty programming, but I seem to recall >> that at least in some pty states, doing a zero-length write in the pty >> master will send an end-of-file to the slave tty. I don't recall the >> details though... > > I really wish someone could help. At least if someone could point me to > some kind of documentation that would be very helpful. The best "doc" > I could find so far is the xterm source code, which I do not really > understand and whose behavior I haven't been able to reproduce yet > (e.g. it seems not to disable ICANON mode, and it doesn't seem to ever > send EOF either, even when sending large chunks of data, yet that data > doesn't get truncated, whereas when I try to to make Emacs send large > amounts of data in ICANON mode without EOFs, it gets truncated). > I don't know what the original problem was (sending large amount of data may hang?) that prompted the removal of ICANON. But as far as xterm goes (if it hasn't changed radically in the last year or so), it does something like this: loop1: try to write min(128 characters, what we want to write) to the pty (128 is half of what POSIX says is the minimum pty buffer size) If write returned what we put in and there is more to write, goto loop1. If write returned less or (-1 and errno is EAGAIN/EWOULDBLOCK), stop writing and select on the fd for write. When select says it is OK to write again, start at loop1. Jan D.