Subject: bug#11415: 24.1.50; Dbus hangs indefinitely during batch mode & daemon startup

From: Michael Albinus <[email-masked]>
Date: Mon, 07 May 2012 16:28:05 +0200

Michael Albinus <[email-masked]> writes:

> In Emacs 24.1.50, `dbus-call-method' changed from a synchronous call to
> an asynchronous one (see etc/NEWS). If Emacs runs in batch mode, it
> doesn't seem to read incoming events. Therefore, the return event of the
> call is not read.
>
> I will see what can be done. Either we must enable Emacs to receive some
> special input events also in batch mode. Or we must check inside
> `dbus-call-method', whether Emacs runs daemonized, and use the blocking
> call then.
>
> I would prefer the first alternative, because receiving D-Bus signals and
> running Emacs as D-Bus enabled server does not work either when Emacs
> does not accept incoming events.

I have debugged further. The problem is in kbd_buffer_get_event of
keyboard.c - it does not read special events when noninteractive. The
following patch cures the problem for me:

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/emacs/src/keyboard.c.~108144~
--- /home/albinus/src/emacs/src/keyboard.c
***************
*** 3801,3806 ****
--- 3801,3807 ----
      }
  #endif	/* subprocesses */

+ #if 0  /* We want to read special events in batch mode.  */
    if (noninteractive
        /* In case we are running as a daemon, only do this before
  	 detaching from the terminal.  */
***************
*** 3811,3816 ****
--- 3812,3818 ----
        *kbp = current_kboard;
        return obj;
      }
+ #endif

    /* Wait until there is input available.  */
    for (;;)
--8<---------------cut here---------------end--------------->8---

However, I don't know whether it has undesired side effects. What do
people think?

Best regards, Michael.