unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* read-event in batch mode
@ 2014-01-31 11:48 Eli Zaretskii
  2014-01-31 13:43 ` Michael Albinus
  2014-01-31 14:09 ` Stefan Monnier
  0 siblings, 2 replies; 13+ messages in thread
From: Eli Zaretskii @ 2014-01-31 11:48 UTC (permalink / raw)
  To: emacs-devel

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?



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2014-02-04 18:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-31 11:48 read-event in batch mode Eli Zaretskii
2014-01-31 13:43 ` Michael Albinus
2014-01-31 14:58   ` Eli Zaretskii
2014-01-31 15:34     ` Stefan Monnier
2014-01-31 16:16       ` Eli Zaretskii
2014-02-04 11:54         ` Michael Albinus
2014-02-04 15:57           ` Eli Zaretskii
2014-02-04 18:16         ` Stefan Monnier
2014-01-31 14:09 ` Stefan Monnier
2014-01-31 15:03   ` Eli Zaretskii
2014-02-02 12:11     ` Nix
2014-02-02 15:59       ` Eli Zaretskii
2014-02-02 19:25         ` Michael Albinus

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).