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: Sun, 17 Oct 2010 19:11:15 -0400 Message-ID: <4CBB8293.2020401@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> 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 1287357315 20272 80.91.229.12 (17 Oct 2010 23:15:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 17 Oct 2010 23:15:15 +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 01:15:11 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 1P7cRb-0002BJ-6D for geb-bug-gnu-emacs@m.gmane.org; Mon, 18 Oct 2010 01:15:11 +0200 Original-Received: from localhost ([127.0.0.1]:43323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7cRa-0001b4-Eh for geb-bug-gnu-emacs@m.gmane.org; Sun, 17 Oct 2010 19:15:10 -0400 Original-Received: from [140.186.70.92] (port=41946 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7cP3-0001FW-OU for bug-gnu-emacs@gnu.org; Sun, 17 Oct 2010 19:12:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P7cP2-00043H-DA for bug-gnu-emacs@gnu.org; Sun, 17 Oct 2010 19:12:33 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P7cP2-00043B-B2 for bug-gnu-emacs@gnu.org; Sun, 17 Oct 2010 19:12:32 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1P7cKg-0008KB-4V; Sun, 17 Oct 2010 19:08: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: Sun, 17 Oct 2010 23:08: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.128735685731992 (code B ref 7225); Sun, 17 Oct 2010 23:08:02 +0000 Original-Received: (at 7225) by debbugs.gnu.org; 17 Oct 2010 23:07:37 +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 1P7cKG-0008Jx-Kw for submit@debbugs.gnu.org; Sun, 17 Oct 2010 19:07:36 -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 1P7cKE-0008Js-K0 for 7225@debbugs.gnu.org; Sun, 17 Oct 2010 19:07:35 -0400 Original-Received: from [192.168.1.4] (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 o9HNBFiu018892 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sun, 17 Oct 2010 19:11:15 -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: <83sk04a2v9.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 17 Oct 2010 19:08: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:40940 Archived-At: On 10/17/2010 6:08 PM, Eli Zaretskii wrote: >> Date: Sun, 17 Oct 2010 17:40:39 -0400 >> From: Ken Brown >> CC: "7225@debbugs.gnu.org"<7225@debbugs.gnu.org> >> >> I haven't yet found an alternative to TIOCGPGRP that works for Cygwin, >> and it may well be that there isn't one. But I think there's a separate >> issue that is not specific to Cygwin. It seems to me that line 6233 of >> process.c is simply wrong, and not just for Cygwin. >> >> When we reach that line, we want the process group ID of the foreground >> process group of the terminal associated with p (which is a shell in the >> most common use case). We don't have TIOCGPGRP, so we don't know how to >> do this. We therefore give up and set gid = p->pid. Is there any >> situation in which this is the right thing to do? It means that (in the >> common use case) we'll send the signal to the shell instead of to the >> process running in the shell. Wouldn't it be better to just return at >> that point and issue a warning message saying that we can't send the signal? > > 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? 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. See below. You seem to be assuming that the process group of the shell will include all of the shell's children. Is that what happens in GNU/Linux? >> What this would mean for Cygwin, once I make the change I proposed (and >> assuming I don't find a better solution), is that the only signals we'll >> be able to send to the foreground process of a shell are SIGINT, >> SIGQUIT, and SIGTSTP, and we'll see a failure message if we try to send >> a different signal. That's better than sending a signal to the wrong >> process. > > It's not the wrong process. The problem is that its children might > not get the signal. It is the wrong process on Cygwin. Here's an example. I start a shell and then run 'cat'. In another shell I run 'ps'. The relevant part of the output is: PID PPID PGID WINPID TTY UID STIME COMMAND 508 920 508 3552 1 1009 18:50:15 /usr/bin/sh I 916 508 916 1832 1 1009 18:50:18 /usr/bin/cat 508 is the PID as well as the PGID of the shell. But cat is in a different process group, even though it's a child of the shell (as we see from the PPID). On the other hand, it has the same controlling tty as the shell, so we'd be in business if we could get the PGID of the foreground process of the controlling tty of the shell. That's what I thought emacs_get_tty_pgrp was doing (according to its comment). When I type C-c C-c, emacs sends a signal to PGID 508, which is not the right thing to do. > So the question is: how to send a signal to the whole process group > with Cygwin? Does Cygwin support the "minus pgid" method of calling > `kill'? Yes.