How to Fix a Stuck Emacs

A very handy tip from Wilfred Hughes:

Emacs 24.5, on OS X at least, sometimes hangs for no apparent reason. I've used this tip several times to get things unhung.

UPDATE: I forgot to add that on OS X you have to either use the -i option or specify Emacs (note capital letter) as the process name.

This entry was posted in General and tagged . Bookmark the permalink.
  • I also noticed that Emacs on OS X hangs on startup for me for no reason often, requiring multiple kills and restarts until somehow it works, then it stays up just fine. I wish I knew why.

    • jcs

      I used to see that too but only with my iMac not with my MacBook. This despite the fact that they were running the exact same software. I think the problem went away with 24.5.

      • No, this is happening on all my Macs, running 24.5.1 as built by Homebrew. Are you using a non-Homebrew version?

        • jcs

          I have no idea why it only happened on the iMac. It is an older machine but its software is up to date and identical to what's on my MacBook.

          I compile Emacs myself right from the tar file. Still, I would think that using Homebrew would give the same results unless they're adding some patches of their own.

          • Does it also happen with Emacs - Q?

          • jcs

            It was very intermittent and not reproducible.

            See the comment from Anders Lindgren below. His remarks on the cause of the problem may explain why it happens on some machines but not on others even though the software is the same.

          • Interesting!

    • Anders Lindgren

      This has been fixed in the upcoming Emacs 25 release. It was caused by input events arriving before the init code was done. The problems were worse on slow machines, when the load was heavy, when disks needed to spin up etc.

      • Haider Rizvi

        Can you point to more details of what's fixed. I have been having a specific problem with org-mode / emacs 24.5.1 pushing cpu to 100% on Mac OSX. I just hit that problem with from

        • Anders Lindgren

          It was fixed in The important change is the block/unblock_input in ns_init_term. This was done on the "emacs-25" branch -- emacsforosx most likely builds from the master branch, which is why you don't see it.

          • Anders Lindgren

            However, this fix is only for startup problems. Try setting debug-on-quit to t and press C-g, that should fire up the debugger, and you can work from there.

          • Thanks for the info! I don't think I'll go to an Emacs 25 nightly build yet, but at least now I know it's been fixed.

      • Sumner Hearth

        This seems to have fixed the issue, (using the homebrew --devel branch). Thanks!

  • asmeurer

    Is there any way to tell what was causing the hanging? This is happening all the time for me starting emacsclient in the terminal (emacs 25.1, OS X).

    • jcs

      Are you getting a traceback? When I do this, I get a traceback and have to quit out of the debugger to continue. You should get a clue from the traceback what the problem is. Or at least you can include it in a bug report.