From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Device 0 is not a termcap terminal device Date: Tue, 01 Sep 2009 19:20:01 -0400 Message-ID: References: <20081003100758.GA1762@muc.de> <200810031625.m93GPZKn023230@mothra.ics.uci.edu> <20090901200826.GA2657@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1251847223 23705 80.91.229.12 (1 Sep 2009 23:20:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 1 Sep 2009 23:20:23 +0000 (UTC) Cc: csant , emacs-devel To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 02 01:20:16 2009 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.50) id 1Mice5-0004mR-Rg for ged-emacs-devel@m.gmane.org; Wed, 02 Sep 2009 01:20:14 +0200 Original-Received: from localhost ([127.0.0.1]:44858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mice5-0003yC-3m for ged-emacs-devel@m.gmane.org; Tue, 01 Sep 2009 19:20:13 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Micdz-0003uZ-Rb for emacs-devel@gnu.org; Tue, 01 Sep 2009 19:20:07 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Micdv-0003o7-AW for emacs-devel@gnu.org; Tue, 01 Sep 2009 19:20:07 -0400 Original-Received: from [199.232.76.173] (port=54646 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Micdv-0003nw-7v for emacs-devel@gnu.org; Tue, 01 Sep 2009 19:20:03 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:28843 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Micdu-00085f-RL for emacs-devel@gnu.org; Tue, 01 Sep 2009 19:20:03 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArcEAEtInUpFpYuS/2dsb2JhbACBU9lrhBsFgkaFKQ X-IronPort-AV: E=Sophos;i="4.44,314,1249272000"; d="scan'208";a="44844044" Original-Received: from 69-165-139-146.dsl.teksavvy.com (HELO pastel.home) ([69.165.139.146]) by ironport2-out.teksavvy.com with ESMTP; 01 Sep 2009 19:18:53 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 4BDE67F24; Tue, 1 Sep 2009 19:20:01 -0400 (EDT) In-Reply-To: <20090901200826.GA2657@muc.de> (Alan Mackenzie's message of "Tue, 1 Sep 2009 20:08:26 +0000") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.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:114970 Archived-At: > A little less that a year ago, I supplied a "me too" to this bug in which > batch programs would crash with the error message > Device 0 is not a termcap terminal device > I have now tracked this bug down: `send-string-to-terminal' crashes in > -batch. To see this, compare the following: Does the patch below help? > The documentation of the function in the Elisp manual for Emacs 22 > just said that the string is sent to "the terminal", which presumable > means stdout. There's a subtle difference between the two, but yes, they used to be pretty much the same. With multi-tty, the difference is made more significant. > In Emacs 23's Elisp, it says the string goes to "the selected frame's > terminal", which is clearly undefined in batch mode. Actually, it is well defined: when Emacs starts it starts with a special frame on a special terminal (a dumb terminal), later on, this terminal is usually deleted and replaced with an X11 or tty terminal, except in batch mode and in daemon mode. Look for the `terminal-frame' variable and its uses in startup.el and frame.el to see it in action. > This change wasn't in the "incompatible changes" section of NEWS, so it > would appear to be a bug. send-string-to-terminal is rarely used, and even more so in batch mode (where you could argue that it worked by accident). That's why nobody noticed the problem (and neither decided to fix it nor to document it). Stefan === modified file 'src/dispnew.c' --- src/dispnew.c 2009-08-26 02:42:52 +0000 +++ src/dispnew.c 2009-09-01 23:09:31 +0000 @@ -6090,8 +6090,9 @@ Lisp_Object string; Lisp_Object terminal; { - struct terminal *t = get_tty_terminal (terminal, 1); + struct terminal *t = get_terminal (terminal, 1); struct tty_display_info *tty; + FILE *out; /* ??? Perhaps we should do something special for multibyte strings here. */ CHECK_STRING (string); @@ -6100,6 +6101,12 @@ if (!t) error ("Unknown terminal device"); + if (t->type == output_initial) + out = stdout; + else if (t->type != output_termcap && t->type != output_msdos_raw) + error ("Device %d is not a termcap terminal device", t->id); + else + { tty = t->display_info.tty; if (! tty->output) @@ -6110,8 +6117,10 @@ fwrite (SDATA (string), 1, SBYTES (string), tty->termscript); fflush (tty->termscript); } - fwrite (SDATA (string), 1, SBYTES (string), tty->output); - fflush (tty->output); + out = tty->output; + } + fwrite (SDATA (string), 1, SBYTES (string), out); + fflush (out); UNBLOCK_INPUT; return Qnil; }