[Geany-Devel] VTE resetting and handling of ^C and ^D

Colomban Wendling lists.ban at herbesfolles.org
Tue Dec 4 22:18:24 UTC 2012


When looking to the VTE code to fix focusing upon middle click, I also
dig into the long-running problems we have on dealing with ^C and ^D.

First, we try to kill the child (the shell we launched) using SIGINT,
but neither BASH nor DASH seem to honor them this way, so we actually
only reset the view, thus leading to report like:

(I think improperly marked as fixed)

You can check it if you want, either by sending SIGINT to a
manually-launched BASH or by checking whether the pid actually quit.
Anyway, you'll see nothing gets killed.

So, I propose to replace this by a SIGHUP.  I attached a patch that does
it, and it works;  but I'm not 100% sure if it's OK to do so, although I
don't see much problem with it.

Patch is 0001-VTE-Fix-killing-the-child.patch.

The other problem is that we reset the terminal upon ^C -- and worse,
upon ^D.  OK, ^C is used to send SIGINT to the running child, which
generally result in it exiting.  But first, one generally expect it to
only kill the running child [1], and not the terminal itself; and this
is important e.g. if the user still want to read the output (e.g. if a
program went wild, it may still have output useful errors).  And then,
legitimate programs handle SIGINT somewhat gracefully -- the excessive
example being Nano which uses ^C as a shortcut.

So, I don't think ^C should reset the terminal/kill the shell, but
rather be handled by the shell.

Now ^D.  An user expects ^D to send EOF to the stdin of the running
child, whatever this might mean to that child;  not to behave like ^C
and certainly not to reset the terminal/kill the shell.

So, to summarize, I think it's important that both ^C and ^D end up
being handled by the shell we run in the VTE, and not by us vainly
trying to do something that looks like almost not so bad.

I search a bit how I could forward ^C and ^D to the VTE child, and
didn't find much in the VTE docs;  but Wikipedia told me that ASCII ETX
and EOT were commonly respectively used to mean ^C and ^D for UNIX
terminals [2] [3].  And indeed, sending those using
`vte_terminal_feed_child()` seems to work just fine.  I however don't
know how portable/reliable this is, so I ask for your knowledge and
opinion here.

Attached patch is

Ah, and note that one can still reset the terminal like before through
the context menu.

So, have you opinions, ideas, remarks, something to say?  Looking
forward to read you on the subject :)


[1] and here we speak of the shell's child, not the VTE child which is
the shell.
[2] https://en.wikipedia.org/wiki/End-of-text_character
[3] https://en.wikipedia.org/wiki/End-of-transmission_character
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-VTE-Fix-killing-the-child.patch
Type: text/x-patch
Size: 780 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20121204/f605e40c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-VTE-Really-send-C-and-D-to-the-terminal-rather-than-.patch
Type: text/x-patch
Size: 1792 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20121204/f605e40c/attachment-0001.bin>

More information about the Devel mailing list