From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.bugs Subject: bug#11102: 24.0.94; C-x C-c from a client frame sometimes kills the whole Emacs process Date: Sat, 14 Apr 2012 13:34:27 +0800 Message-ID: <87sjg6uba4.fsf@gnu.org> References: <87obreaups.fsf@gnu.org> <83wr62yocw.fsf@gnu.org> <83mx6f3der.fsf@gnu.org> <87zkaeud3l.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1334381748 31665 80.91.229.3 (14 Apr 2012 05:35:48 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 14 Apr 2012 05:35:48 +0000 (UTC) Cc: Juanma Barranquero , 11102@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Apr 14 07:35:47 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 1SIveE-0007F2-J3 for geb-bug-gnu-emacs@m.gmane.org; Sat, 14 Apr 2012 07:35:46 +0200 Original-Received: from localhost ([::1]:43816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIveD-0001TU-HO for geb-bug-gnu-emacs@m.gmane.org; Sat, 14 Apr 2012 01:35:45 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:51700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIveA-0001Sy-Fr for bug-gnu-emacs@gnu.org; Sat, 14 Apr 2012 01:35:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SIve8-0006B3-JU for bug-gnu-emacs@gnu.org; Sat, 14 Apr 2012 01:35:41 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SIve8-0006Ak-Fb for bug-gnu-emacs@gnu.org; Sat, 14 Apr 2012 01:35:40 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SIvfS-0008Rw-61 for bug-gnu-emacs@gnu.org; Sat, 14 Apr 2012 01:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Chong Yidong Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Apr 2012 05:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11102 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11102-submit@debbugs.gnu.org id=B11102.133438176632417 (code B ref 11102); Sat, 14 Apr 2012 05:37:02 +0000 Original-Received: (at 11102) by debbugs.gnu.org; 14 Apr 2012 05:36:06 +0000 Original-Received: from localhost ([127.0.0.1]:57914 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SIveV-0008Qm-O9 for submit@debbugs.gnu.org; Sat, 14 Apr 2012 01:36:05 -0400 Original-Received: from fencepost.gnu.org ([208.118.235.10]:56297) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SIveT-0008QO-My for 11102@debbugs.gnu.org; Sat, 14 Apr 2012 01:36:03 -0400 Original-Received: from bb220-255-229-180.singnet.com.sg ([220.255.229.180]:49839 helo=ulysses) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SIvd6-0001Vn-Dr; Sat, 14 Apr 2012 01:34:37 -0400 In-Reply-To: <87zkaeud3l.fsf@gnu.org> (Chong Yidong's message of "Sat, 14 Apr 2012 12:55:10 +0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.95 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:59031 Archived-At: Chong Yidong writes: > If on a client frame created by "emacsclient -c -n" the C-x C-c command > kills Emacs, that is indeed a bug. My guess would be that the `client' > frame parameter is not getting correctly assigned to the newly-created > frame on Windows, due to the extra juggling in the #ifdef WINDOWSNT code > segment Juanma pointed out. Took a quick look, and indeed the "set tty = 1 on Windows" hack does seem to be at fault. Here's my diagnosis: if (tty || !current_frame) { display = (const char *) ttyname (0); /* Arg is ignored. */ current_frame = 0; tty = 1; } ... /* --no-wait implies --current-frame on ttys when there are file arguments or expressions given. */ if (nowait && tty && argc - optind > 0) current_frame = 1; When tty = 1, if there are also -n and filename arguments, emacsclient assumes that a current Emacs frame must be used. This assumption is not correct if the tty = 1 is because of the Window hack. As a result, the server calls `server-select-display', which ends up trying to create a new frame on the display ttyname(0), contra the "Arg is ignored" comment. That new frame, if created, lacks the `client' frame parameter for C-x C-c to work right. Does the following patch DTRT? This is an attempt at making a minimal change, for Emacs 24.1. For the trunk, I think it is worth trying to untangle the logic properly, but that will needs Someone(tm) to work on it who has access to a Windows box. === modified file 'lisp/server.el' *** lisp/server.el 2012-04-04 17:13:00 +0000 --- lisp/server.el 2012-04-14 05:29:24 +0000 *************** *** 1136,1141 **** --- 1136,1145 ---- (setq frame (cond ((and use-current-frame + ;; On Windows, we pass -tty as a hack, using + ;; a bogus display name. + (or (not (eq window-system 'w32)) + (equal display "CONOUT$")) (or (eq use-current-frame 'always) ;; We can't use the Emacs daemon's ;; terminal frame.