On 18/1/2025 12:18 am, Michael Albinus wrote:
It looks like you access the container via ssh. An altenative would be
to install recent Tramp 2.7.2 from GNU ELPA, and use its built-in docker
method.
Ah, I forgot to mention I am on the latest Emacs (built from master
recently) thus using Tramp 2.8.0pre but I also (while trying to pinpoint
the source) tried with Emacs 29.4 which uses Tramp 2.6.3.
So while I am using the podman and podmancp methods, perhaps creating my
own since I need some heavier customisation on listing containers for
completion etc that point is moot since Tramp maintains an ssh
connection for its control on the remote.
Additionally, even if Tramp never established an ssh connection to the
remote, Podman can defer to the systems ssh binary when requested with
some commands.
In general I think sending SIGKILL to ssh (or any Tramp process) as the
/first/ attempt is too heavy handed. In this case it is leaving dozens
of ptys open on the remote, and causes container shutdown and VM
shutdowns to hang until Podman or the hypervisor decides to kill the
container or VM (while these extra ptys and orphaned shell sessions
infinitely wait for traffic which will never arrive). This also hangs
Emacs in at least one case I saw.
Redefining tramp-cleanup-all-connections in my init.el by simply
copy-pasting it and changing a single line at the end of the function from
(when (processp (get-buffer-process name)) (delete-process name))
to
(when (processp (get-buffer-process name)) (signal-process name
'SIGTERM))
resolves the issue. Now Tramp kills ssh gracefully which correctly
terminates and closes the remote pty and shell process.
Additionally signal-process-functions can be used to define functions to
send signals to processes when signal-process is called, so Tramp could
first attempt SIGTERM and wait say.. 3 seconds (some configurable time)
and then attempt another signal etc and finally SIGKILL (with a message
logged to *Messages* to indicate the dangerous SIGKILL'ing of the process).
I know that's a decent wall of text, I just wanted to give more context.
/Jordan