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:39:59 -0400 Message-ID: <4CBB894F.8010203@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 1287358962 25150 80.91.229.12 (17 Oct 2010 23:42:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 17 Oct 2010 23:42:42 +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:42:41 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 1P7cs9-0002nZ-Sp for geb-bug-gnu-emacs@m.gmane.org; Mon, 18 Oct 2010 01:42:39 +0200 Original-Received: from localhost ([127.0.0.1]:51985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7cs8-0000Ig-Ei for geb-bug-gnu-emacs@m.gmane.org; Sun, 17 Oct 2010 19:42:36 -0400 Original-Received: from [140.186.70.92] (port=54924 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7cs1-0000HU-3R for bug-gnu-emacs@gnu.org; Sun, 17 Oct 2010 19:42:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P7crz-0007yC-Tp for bug-gnu-emacs@gnu.org; Sun, 17 Oct 2010 19:42:28 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38109) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P7crz-0007y8-S5 for bug-gnu-emacs@gnu.org; Sun, 17 Oct 2010 19:42:27 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1P7cmk-0008Vo-OM; Sun, 17 Oct 2010 19:37: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:37: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.128735858132704 (code B ref 7225); Sun, 17 Oct 2010 23:37:02 +0000 Original-Received: (at 7225) by debbugs.gnu.org; 17 Oct 2010 23:36:21 +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 1P7cm5-0008VR-8K for submit@debbugs.gnu.org; Sun, 17 Oct 2010 19:36:21 -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 1P7cm2-0008VM-K9 for 7225@debbugs.gnu.org; Sun, 17 Oct 2010 19:36:19 -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 o9HNdxUF023595 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Sun, 17 Oct 2010 19:39:59 -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: <4CBB8293.2020401@cornell.edu> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 17 Oct 2010 19:37: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:40941 Archived-At: On 10/17/2010 7:11 PM, Ken Brown wrote: > 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 I've just checked that the same thing happens in GNU/Linux (or at least in the GNU/Linux system I have access to). Start a shell, start 'cat', and the PGID of cat will not be the same as that of the shell.