Refrain from immediate `delete-process` in `tramp-cleanup-all-connections`

Jordan Ellis Coppard <[email protected]> Fri, 17 Jan 2025 22:10:28 +0900
Newsgroups gmane.emacs.tramp
Message-ID <[email protected]>
Hi there,


I've recently been trying to use a container-focused workflow (said 
containers running locally, use TRAMP for a hermetic dev environment).

It's.. painful and while debugging problems (like vc-refresh causing 
Emacs to freeze when used with TRAMP.. which I still haven't figured out 
yet) I noticed more and more orphaned shells, with increasing pty 
creations on the remote.

It looks like tramp-cleanup-all-connections calls `delete-process` which 
is documented as sending SIGKILL. Sending SIGKILL to ssh will prevent 
any cleanup and orphan the remote shell TRAMP is using, including any 
other processes.

Perhaps TRAMP should be sending a more graceful signal, waiting for some 
configurable timeout time, then trying another signal etc and finally 
sending SIGKILL with a message to the user informing them if the latter 
occurs.

It looks like to me like signal-process should be used instead, and the 
logic described above can be supplied via signal-process-functions. Both 
of these are on the same info page as delete-process (which is an alias 
for kill-process).

This logic is present in at least TRAMP 2.6.3 and using `kill -9 
$SSHPID` externally produces the same result indicating it is the use of 
`delete-process` causing this problem.


/Jordan