From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Brown Newsgroups: gmane.emacs.bugs Subject: bug#7225: 23.2.50; [PATCH] C-c C-c doesn't work in shell mode (Cygwin) Date: Mon, 18 Oct 2010 07:58:35 -0400 Message-ID: <4CBC366B.9060906@cornell.edu> References: <4CB8E584.1090800@cornell.edu> <83iq12bnjj.fsf@gnu.org> <4CB99E2C.5030904@cornell.edu> <838w1yb757.fsf@gnu.org> <4CBB6D57.3040108@cornell.edu> <83sk04a2v9.fsf@gnu.org> <4CBB8293.2020401@cornell.edu> 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 1287403964 21183 80.91.229.12 (18 Oct 2010 12:12:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 18 Oct 2010 12:12:44 +0000 (UTC) Cc: "7225@debbugs.gnu.org" <7225@debbugs.gnu.org> To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 18 14:12:42 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1P7oa2-0000E8-6v for geb-bug-gnu-emacs@m.gmane.org; Mon, 18 Oct 2010 14:12:42 +0200 Original-Received: from localhost ([127.0.0.1]:51669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7oa1-0007iH-Jy for geb-bug-gnu-emacs@m.gmane.org; Mon, 18 Oct 2010 08:12:41 -0400 Original-Received: from [140.186.70.92] (port=49374 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7oZr-0007hC-AK for bug-gnu-emacs@gnu.org; Mon, 18 Oct 2010 08:12:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P7oZp-0003Q9-K1 for bug-gnu-emacs@gnu.org; Mon, 18 Oct 2010 08:12:31 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57484) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P7oZp-0003Q5-IJ for bug-gnu-emacs@gnu.org; Mon, 18 Oct 2010 08:12:29 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1P7oJu-0005gv-7a; Mon, 18 Oct 2010 07:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ken Brown Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 Oct 2010 11:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7225 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 7225-submit@debbugs.gnu.org id=B7225.128740291021861 (code B ref 7225); Mon, 18 Oct 2010 11:56:02 +0000 Original-Received: (at 7225) by debbugs.gnu.org; 18 Oct 2010 11:55:10 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P7oJ3-0005gY-PU for submit@debbugs.gnu.org; Mon, 18 Oct 2010 07:55:10 -0400 Original-Received: from granite1.mail.cornell.edu ([128.253.83.141] helo=authusersmtp.mail.cornell.edu) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P7oJ1-0005gG-2D for 7225@debbugs.gnu.org; Mon, 18 Oct 2010 07:55:07 -0400 Original-Received: from [127.0.0.1] (cpe-67-249-196-94.twcny.res.rr.com [67.249.196.94]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id o9IBwljm013269; Mon, 18 Oct 2010 07:58:49 -0400 (EDT) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 In-Reply-To: X-Antivirus: avast! (VPS 101018-0, 10/18/2010), Outbound message X-Antivirus-Status: Clean X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 18 Oct 2010 07:56:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:40950 Archived-At: On 10/18/2010 2:59 AM, Eli Zaretskii wrote: >> Date: Sun, 17 Oct 2010 19:11:15 -0400 >> From: Ken Brown >> CC: "7225@debbugs.gnu.org"<7225@debbugs.gnu.org> >> >>> The problem that code is trying to solve is how to send a signal to >>> the whole process group starting at the shell (or whatever process is >>> the group leader). Failure to do so could mean that the immediate >>> subprocess of Emacs will get the signal, but its children will not. >>> If the signal kills the subprocess, its children may remain behind as >>> orphans. >> >> Am I misunderstanding the comment preceding the definition of >> emacs_get_tty_pgrp? > > No, you understand it correctly. > >> Here's what it says: >> >> /* Return the foreground process group for the tty/pty that >> the process P uses. */ >> >> That's not the same as the process group of the shell, at least in >> Cygwin. > > Right, these are in general two different groups. > >> You seem to be assuming that the process group of the shell will >> include all of the shell's children. > > No, I didn't assume that, sorry for possibly confusing wording. > > There's a misunderstanding here: you were talking about the case of > interrupting a command run by a shell, whereas I was talking about the > case of sending a signal to a process that is not the shell, or > perhaps about signaling the shell itself. > > For the case you ware talking about, sending the signal to the shell > is indeed the wrong thing, because the shell makes any foreground > command it runs into a separate process group, and it's that process > group that we want to send the signal to. But for that case, you > already found the right solution: use SIGNALS_VIA_CHARACTERS. This > does exactly the right thing, like the INTR character typed on the > tty. > > What's left is the case of signals other that SIGINT/SIGQUIT/SIGTSTP. > In that case, in the absence of TIOCGPGRP, the code in process.c > supports sending the signal only to p->pid's process group (if p->pid > is not a group leader, only it itself will be signaled). I think this > is better than punting, because if there _is_ a process group of which > p->pid is the leader, doing what the code does now will not leave > orphans, processes other than p->pid that belonged to p->pid's group. > It is true that this group might not be the foreground process group, > but with signals other than SIGINT/SIGQUIT/SIGTSTP, this matters much > less, I think. OK, I'm glad we understand each other now. But I still think line 6233 is wrong. That code gets executed only when current_group is non-nil. (As far as I know, the only use case for this is in shell mode, when we're trying to signal the foreground process; but I haven't done an exhaustive search to see if there are other cases.) According to the documentation preceding process_send_signal, we should not be sending a signal to p->pid in that case. So I think punting is better than what's done now. When current_group is nil, on the other hand, we do want to send a signal to p->pid and its process group, and this is correctly taken care of in line 6104. As a practical matter, I don't think the problem is serious, but I do think it's a bug. Anyway, I'll go ahead with my patch, since we both agree that it's the right fix for the original bug I reported.