5

I was trying to operate on remote host using eshell and was disappointed to discover that majority of operations would hang emacs for several seconds.

I found it surprising considering that normally eshell executes subprocesses asynchronously and upon further investigation found that eshell reopens TRAMP connections for any external command.

Below is sequence of commands which I pass eshell buffer:

~ $ cd /ssh:aws:
/ssh:aws:/home/ubuntu $ ps
  PID TTY          TIME CMD
12212 pts/3    00:00:00 ps
/ssh:aws:/home/ubuntu $ 

And messages which indicate that eshell opens connection several times:

Tramp: Opening connection for aws using ssh...
Tramp: Sending command `exec ssh   -o ControlPath=/tmp/tramp.32766gT7.%r@%h:%p -o ControlMaster=auto -o ControlPersist=no -e none aws'
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on `aws'
Tramp: Opening connection for aws using ssh...done
Tramp: Opening connection for aws using ssh...
Tramp: Sending command `exec ssh -q   -o ControlPath=/tmp/tramp.32766gT7.%r@%h:%p -o ControlMaster=auto -o ControlPersist=no -e none aws'
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on `aws'
Tramp: Opening connection for aws using ssh...done

Is it a limitation of eshell that it needs to spawn new shell every invocation of non-builtin command or could I make it use TRAMP shell which, judging by list-processes, appears to persist since I first navigated to a path handled by TRAMP?

1

1 Answer 1

4

eshell commands are send using start-file-process. This spawns an asynchronous process; and Tramp handles them the way you have seen.

It is not an error of Tramp a priori; dumb Tramp does what it is instructed to do ...

8
  • Do you have some ideas how this imperfect behavior of eshell can be improved? If I understand the issue of slow eshell+tramp correctly: How can eshell be made to reuse a TRAMP connection? Jan 24, 2015 at 12:39
  • 2
    A "reuse" of a Tramp connection would require to apply process-file instead of start-file-process. But this would prevent interactive commands, which require input. Therefore, eshell always applies start-file-process, because it doesn't know in advance whether an arbitrary command is interactive, or not. Maybe one could distinguish between interactive and noninteractive commands in eshell by syntactic means, but nobody has added such feature to eshell. Jan 25, 2015 at 13:43
  • Another idea has just come to me: What if eshell would open a second persistent connection for interactive commands, and would reuse it? Then we could avoid the long waiting for remote prompt etc. every time, isnt' that true? Feb 12, 2015 at 9:02
  • 1
    Would be possible. Write a comment to Emacs bug report #13677, which discusses eshell and Tramp cooperation. Maybe somebody picks this up, and implements. Feb 13, 2015 at 13:26
  • 1
    One could use a different synatx for a command to be applied synchronously (via process-file) or asynchronously (via start-file-process). Eshell does something similar for distinguishing internal and external commands, cf *ls and ls. Feb 22, 2015 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.