From: Masahiro Yamada <masahiroy@kernel.org>
To: help-gnu-emacs@gnu.org
Subject: Ctrl-G in emacs does not send SIGINT to the parent shell. How did you do that?
Date: Sun, 27 Jun 2021 21:25:38 +0900 [thread overview]
Message-ID: <CAK7LNAT=VYrooMfauK5TUqdqCRKoiBXJvoj-wWiaPdnLxx2BgQ@mail.gmail.com> (raw)
Hello.
I found this thread reported in 2012:
https://lists.gnu.org/archive/html/bug-gnu-emacs/2012-07/msg00311.html
It reported that Ctrl-G in an emacs running in a terminal
sends a SIGINT to the parent shell.
I tested it in newer Emacs version (Emacs 26.3), and
found the behavior was opposite.
So, something has changed since then.
I'd like to know what was changed.
The following is the detailed steps for my tests.
I invoked 'emacs -nw' from bash running in a terminal.
Let's say I am using the terminal, /dev/pts/28.
I used 'stty' from another terminal in order to confirm
'intr' key was changed to ^G from ^C.
$ stty -a -F /dev/pts/28
speed 38400 baud; rows 27; columns 224; line = 0;
intr = ^G; quit = ^G; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
[ snip ]
I used strace to check if SIGINT was delivered
when I pressed Ctrl-G.
I opened another terminal, and ran:
$ sudo strace -e trace=signal -p <pid-of-emacs>
I opened yet anther terminal, and ran:
$ sudo strace -e trace=signal -p <pid-of-parent-shell>
When I pressed Ctrl-G in the Emacs window, I saw SIGINT logs
in the first terminal, which is tracing the emacs.
In contrast, I saw nothing in the second one, which is tracing
the parent shell.
In my understanding, when a user provides keyboard-interrupt,
all the foreground processes in that terminal will receive SIGINT.
How can Emacs block SIGINT from being delivered to the parent shell?
BTW, I noticed this when I was reading this article:
https://www.cons.org/cracauer/sigint.html
That article says:
"If C-g is used in Emacs, both the shell and Emacs will have received SIGINT.
Emacs will not exit, the user used C-g as a normal editing keystroke,
he/she does not want the script to be aborted on C-g."
It also contradicts to the current behavior of Emacs.
I am curious how the current behavior was archieved.
Thanks.
--
Best Regards
Masahiro Yamada
next reply other threads:[~2021-06-27 12:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-27 12:25 Masahiro Yamada [this message]
2021-06-27 12:52 ` Ctrl-G in emacs does not send SIGINT to the parent shell. How did you do that? Emanuel Berg via Users list for the GNU Emacs text editor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAK7LNAT=VYrooMfauK5TUqdqCRKoiBXJvoj-wWiaPdnLxx2BgQ@mail.gmail.com' \
--to=masahiroy@kernel.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).