* Ctrl-G in emacs does not send SIGINT to the parent shell. How did you do that?
@ 2021-06-27 12:25 Masahiro Yamada
2021-06-27 12:52 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 2+ messages in thread
From: Masahiro Yamada @ 2021-06-27 12:25 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Ctrl-G in emacs does not send SIGINT to the parent shell. How did you do that?
2021-06-27 12:25 Ctrl-G in emacs does not send SIGINT to the parent shell. How did you do that? Masahiro Yamada
@ 2021-06-27 12:52 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 2+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-06-27 12:52 UTC (permalink / raw)
To: help-gnu-emacs
Masahiro Yamada wrote:
> 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.
:O
I like this one :)
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-27 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-27 12:25 Ctrl-G in emacs does not send SIGINT to the parent shell. How did you do that? Masahiro Yamada
2021-06-27 12:52 ` Emanuel Berg via Users list for the GNU Emacs text editor
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).