emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

read-event in batch mode


From: Eli Zaretskii
Subject: read-event in batch mode
Date: Fri, 31 Jan 2014 13:48:12 +0200

Currently, read-event waits forever when called in batch mode.  This
is because of the following fragment from kbd_buffer_get_event:

  #ifndef HAVE_DBUS  /* We want to read D-Bus events in batch mode.  */
    if (noninteractive
        /* In case we are running as a daemon, only do this before
           detaching from the terminal.  */
        || (IS_DAEMON && daemon_pipe[1] >= 0))
      {
        int c = getchar ();
        XSETINT (obj, c);
        *kbp = current_kboard;
        return obj;
      }
  #endif        /* ! HAVE_DBUS  */

The call to getchar will wait indefinitely, until something is typed
on the keyboard.

Worse, if Emacs is built with D-Bus, this fragment is bypassed
(including if Emacs is run in daemon mode!), and then read-event does
honor the timeout.  The net effect is that writing code that waits for
events and works on all platforms is tricky at best.

This was discovered while debugging the problems of
file-notify-tests.el, see bug #16519 for more details and context.

Does any port for a supported platform need this fragment, or can we
safely delete it?  What about the daemon -- does it need this "when
detaching from the terminal", and if so, why?

In any case, I think we need to document this deviant behavior, at
least for now, because there's no hint of it anywhere in the docs.  Of
course, sit-for is also affected by that.

Comments?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]