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