delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/10/16/14:07:08

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.2 required=5.0 tests=AWL,BAYES_40,SPF_NEUTRAL,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Message-ID: <4CB9E9C0.3000509@cornell.edu>
Date: Sat, 16 Oct 2010 14:06:56 -0400
From: Ken Brown <kbrown AT cornell DOT edu>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4
MIME-Version: 1.0
To: cygwin <cygwin AT cygwin DOT com>
Subject: Re: Sending signals to a subprocess
References: <4CB9DE15 DOT 8010308 AT cornell DOT edu>
In-Reply-To: <4CB9DE15.8010308@cornell.edu>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 10/16/2010 1:17 PM, Ken Brown wrote:
> I could use some help fixing a longstanding bug in the Cygwin build of
> emacs, in which emacs is unable to send signals to subprocesses.  A
> symptom from the user's point of view is that one cannot interrupt a
> process in shell mode by typing C-c C-c.  I've found a workaround that
> handles that case (SIGINT), as well as SIGQUIT and SIGTSTP.  But as long
> as I'm fixing this, I'd like to do it right and figure out how to handle
> all signals.
>
> This boils down to finding the right process group ID to pass to 'kill'.
> On systems that have TIOCGPGRP, emacs uses the following code (in
> src/process.c) to get this ID:
>
> /* Return the foreground process group for the tty/pty that
>      the process P uses.  */
> static int
> emacs_get_tty_pgrp (p)
>        struct Lisp_Process *p;
> {
>     int gid = -1;
>
> #ifdef TIOCGPGRP
>     if (ioctl (p->infd, TIOCGPGRP,&gid) == -1&&  ! NILP (p->tty_name))
>       {
>         int fd;
>         /* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the
> 	 master side.  Try the slave side.  */
>         fd = emacs_open (SDATA (p->tty_name), O_RDONLY, 0);
>
>         if (fd != -1)
> 	{
> 	  ioctl (fd, TIOCGPGRP,&gid);
> 	  emacs_close (fd);
> 	}
>       }
> #endif /* defined (TIOCGPGRP ) */
>
>     return gid;
> }
>
> What's the right way to do this in Cygwin?

I guess it's clear from the context, but I should have said that the 
problem only arises when emacs has to communicate with the subprocess 
through a tty that is not the controlling tty of emacs.  So tcgetpgrp() 
doesn't work.

Ken

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019