> On Jan 28, 2025, at 5:17 AM, Michael Albinus <[email protected]> wrote:
>
> JD Smith <[email protected]> writes:
>
> Hi,
>
>> In developing an application that uses APC codes (like
>> "\x1b_...\x1b/") to communicate with an external process, I noticed
>> that when I try this with remote processes, TRAMP does not faithfully
>> pass binary sequences on to the process. I tracked it down to the use
>> of the flags "-t -t" in the ssh call (the backend I am using).
>
> Not so easy to change in general. The "-t -t" for ssh/scp direct async
> connections was added by intention, due to bug#71050 and bug#71259.
Thanks for your help. I am on TRAMP version: 2.7.2.0.20250101.91903.
>> I was
>> able to lift that restriction with:
>>
>> (setf (alist-get 'tramp-direct-async (alist-get "ssh" tramp-methods nil nil
>> #'equal)) '(("")))
>>
>> But this feels rather hackish.
>
> The Tramp manual describes how to change arguments in tramp-methods, see
> (info "(tramp) Predefined connection information") . In your case, I
> recommend to add to your init file
>
> --8<---------------cut here---------------start------------->8---
> (add-to-list 'tramp-connection-properties (list "/ssh:" "direct-async" t))
> --8<---------------cut here---------------end--------------->8---
>
> Could you pls confirm that this works for you?
Unfortunately this does not work for me. I had formerly used:
(connection-local-set-profile-variables
'remote-direct-async-process
'((tramp-direct-async-process . t)))
(connection-local-set-profiles
'(:application tramp :protocol "ssh")
'remote-direct-async-process)
These settings appear to work. I can see via `M-x list-processes' the direct
call to `ssh -q -e ...' for the remote process, and binary data are passed to
the remote process without interference. These settings also seem to persist
across Emacs sessions, possibly via .emacs.d/tramp.
If I remove that file, and try your recommend settings, it does not work. The
process remains `/bin/sh -i', and binary data do not get sent correctly to the
process. Neither does setting `tramp-direct-async-process=t' work. So I'm
unsure of which settings to use.
BTW, I'd prefer to enable direct-async _only_ for the processes my package
creates, not for _all_ SSH processes, leaving that to the user.
But even with direct-async enabled (with connection-local-set-profiles), I'm
confronted with another problem. My application sends binary data (APC
commands) AND also sends signals (SIGUSR2) to communicate with the remote
process. The situation appears to be as follows:
With direct-async-process: binary data ✓; signals ⨉ [1]
Without direct-async-process: binary data ⨉; signals ✓ [2]
[1] The process is a direct `ssh -q -e` command, binary data is correctly
passed, but any signals from Emacs (even C-c C-c) result in the process dying
with, e.g.:
: C-c C-c
Process X exited abnormally with code 255
[2] The process is `/bin/sh -i`, binary data get mangled when sent to the
process, but signals are correctly propagated and received by the remote
process.
To summarize, it appears I have quite specific needs here. I'm looking for a
combination of settings that:
Apply only to the processes my package creates.
Allow faithful delivery of binary data to the process (a la direct-async).
Allow signals from emacs to correctly reach the remote process (a la a
/bin/sh-wrapped remote process).
Any ideas to try? Thanks again for your assistance.