2

After several years of being annoyed of Emacs on Ubuntu (not Mac via brew) having a ~2-3 second delay before displaying file contents at startup I finally decided to debug this.

I ran strace -r emacs and piped all output to a file. Reading through the file I noticed that there were only three syscalls that took longer than 10ms and they were all pselect6 calls. One of the calls in particular was taking a lot of time (if you're not immediately familiar with -r it shows the time between syscalls): 0.000499 pselect6(4, [3], [], NULL, {1, 996507900}, {NULL, 8}) = 0 (Timeout) 1.997844 ioctl(3, FIONREAD, [0]) = 0 and tracing that back to the open call with fd 3: 0.000000 open("/dev/tty", O_RDWR|O_NOCTTY) = 3

So Emacs is timing out, waiting for user input on startup?

This occurs regardless of what init scripts I use and I've tried both enabling and disabling the splash screen. All to no avail, the 2 second delay persists.

The only thing that seems to affect this 2 second pause is to hit a key, which will take me directly to the file you wanted to open.

I've tried installing both Emacs 23 and 24 and both are affected.

Here is a screenshot of what Emacs looks like while waiting: https://i.stack.imgur.com/uR4wY.jpg And here is after the 2 seconds are up and scratch has loaded: https://i.stack.imgur.com/OmLep.jpg

Does anyone know how to get emacs to not wait for input on /dev/tty?

Edit: Here's the entire strace log from starting up emacs: https://paste.ee/r/cL5jP

Oscar
  • 121
  • 2
  • Emacs does not do this out of the box. First things first: can you reproduce this with `emacs -q`? with `emacs -Q`? with `emacs -Q -nw`? – Gilles 'SO- stop being evil' Oct 01 '16 at 21:28
  • Does this happen when `TERM` is set to `vt102`? I.e. when you do `TERM=vt102 emacs`? Emacs has some special-case code for determining xterm's capabilities. – jch Oct 02 '16 at 15:48
  • @Gilles No difference using those options. – Oscar Oct 03 '16 at 17:36
  • @jch That does fix the delay. It doesn't quite explain why I'm affected while my coworkers are not. Even on the same host – Oscar Oct 03 '16 at 17:37
  • Are you running the same terminal emulator? Are you starting Emacs in the exact same manner? – jch Oct 03 '16 at 19:23
  • @jch I'm currently on Windows running the new Bash but I've had the same issues on Ubuntu running on its own too. And yes, same terminal and same startup of emacs (just running /usr/bin/emacs) – Oscar Oct 03 '16 at 20:35
  • @jch After your tip about the $TERM I found this thread: https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-03/msg00318.html That issue sounds exactly like what I am experiencing. I don't know what to do to fix the issue though. – Oscar Oct 03 '16 at 21:25
  • That thread suggests your terminal (perhaps gnome-terminal?) is mendaciously setting TERM to `xterm`, which causes emacs to do some xterm-specific queries on startup, but your terminal isn't actually xterm-compatible, so those queries time out. If so, the fix is to switch to a different terminal emulator, or override TERM to something else (e.g. in your `~/.bashrc`). – user20151 Jun 12 '20 at 22:46

0 Answers0