GNU bug report logs - #76943
30.1; comint-interrupt-subjob does not interrupt process in inferior-python

Previous Next

Package: emacs;

Reported by: Garid Zorigoo <garidzorigoo <at> gmail.com>

Date: Tue, 11 Mar 2025 15:28:01 UTC

Severity: normal

Found in version 30.1

Done: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: kobarity <kobarity <at> gmail.com>
To: Mattias EngdegÄrd <mattias.engdegard <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 76943 <at> debbugs.gnu.org, Garid Zorigoo <garidzorigoo <at> gmail.com>
Subject: bug#76943: 30.1; comint-interrupt-subjob does not interrupt process in inferior-python
Date: Fri, 14 Mar 2025 01:13:29 +0900
Eli Zaretskii wrote:
> 
> > From: Garid Zorigoo <garidzorigoo <at> gmail.com>
> > Date: Thu, 13 Mar 2025 11:04:23 +0900
> > 
> > 
> > I found a work around, not sure how & why.
> > Changing the value of comint-ptyp seems to make comint-interrupt-subjob work:
> > 
> >  (setq comint-ptyp nil)
> > 
> > Hope this helps.
> > 
> > I believe that inferior-python should be able to interrupt subjobs
> > by default (i.e. without the user changing the above variable value).
> 
> kobarity, any comments or suggestions?

This turned out to be an effect of the setting to make the tty RAW,
which Mattias and I did as part of #68559.

(defconst python-shell-setup-code
  "\
try:
    import tty
except ImportError:
    pass
else:
    tty.setraw(0)"
  "Code used to setup the inferior Python processes.")

This is to disable echo back on MacOS, so there is a workaround to
limit this setting to MacOS only.  That would not solve the
`comint-interrupt-subjob' problem on MacOS, though.

`comint-ptyp' is passed as the CURRENT-GROUP argument of
`interrupt-process' function.  It is finally processed by the
process_send_signal function in process.c.  If CURRENT-GROUP is
non-nil, it first try to send the control character instead of sending
the signal.  However, I believe the control character is ignored
because tty is set to RAW by the above code.

I feel it would be better for process_send_signal to check if the tty
is RAW, but I am not sure if that is appropriate.

Since process_send_signal checks whether control characters such as
VINTR are valid, we can also avoid this problem by disabling VINTR as
follows.

(defconst python-shell-setup-code
  "\
try:
    import tty
    import termios
except ImportError:
    pass
else:
    tty.setraw(0)
    attr = termios.tcgetattr(0)
    attr[-1][termios.VINTR] = b'\x00'
    termios.tcsetattr(0, termios.TCSANOW, attr)"
  "Code used to setup the inferior Python processes.")

In summary, there are at least four possible options.

1. Set `comint-ptyp' to nil.
2. Improve process_send_signal to check if tty is RAW.
3. Disable VINTR in addition to making the tty RAW.
4. Do not set tty to RAW except on MacOS.

If we choose 4, I believe MacOS requires one of 1-3.




This bug report was last modified 89 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.