all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: emacs-devel@gnu.org
Cc: 1082@emacsbugs.donarmstrong.com
Subject: Re: 23.0.60; read-char unexpectedly halts execution of script
Date: Mon, 06 Oct 2008 15:35:28 -0400	[thread overview]
Message-ID: <87iqs5wm7z.fsf@cyd.mit.edu> (raw)
In-Reply-To: <87hc7pr16r.fsf@cyd.mit.edu> (Chong Yidong's message of "Mon, 06 Oct 2008 15:08:44 -0400")

Chong Yidong <cyd@stupidchicken.com> writes:

>> Let filter.el consist of the forms:
>>
>>    (defun bc-filter (proc string)
>>      (message "%s" string))
>>
>>    (message "starting")
>>    (setq bc (start-process "bc" nil "/usr/bin/bc"))
>>    (set-process-filter bc 'bc-filter)
>>
>>    (while t
>>      (let ((char (read-char nil nil 0.1)))
>>        (message "char: %s" char)))
>>
>> Where "/usr/bin/bc" is the GNU arbitrary precision calculator. Now:
>>
>>    mt-computer:~ mt$ emacs --script filter.el
>>    starting
>>    mt-computer:~ mt$
>>
>> I expect non-termination in this case
>
> This broke when SYNC_INPUT became the default.

To pin it down further, this breakage seems to be due to not using
SA_RESTART in the signal handler.  If we set SA_RESTARTi in sysdep.c,
the problem disappears.  Stefan, could you comment?

signal_handler_t
sys_signal (int signal_number, signal_handler_t action)
{
  struct sigaction new_action, old_action;
  sigemptyset (&new_action.sa_mask);
  new_action.sa_handler = action;
#if defined (SA_RESTART) && ! defined (BROKEN_SA_RESTART) && !defined(SYNC_INPUT)
  /* Emacs mostly works better with restartable system services. If this
     flag exists, we probably want to turn it on here.
     However, on some systems this resets the timeout of `select'
     which means that `select' never finishes if it keeps getting signals.
     BROKEN_SA_RESTART is defined on those systems.  */
  /* It's not clear why the comment above says "mostly works better".  --Stef
     When SYNC_INPUT is set, we don't want SA_RESTART because we need to poll
     for pending input so we need long-running syscalls to be interrupted
     after a signal that sets the interrupt_input_pending flag.  */
  new_action.sa_flags = SA_RESTART;
#else
  new_action.sa_flags = 0;
#endif
  sigaction (signal_number, &new_action, &old_action);
  return (old_action.sa_handler);
}




  parent reply	other threads:[~2008-10-06 19:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-06 19:08 23.0.60; read-char unexpectedly halts execution of script Chong Yidong
2008-10-06 19:34 ` bug#1082: " Lennart Borgman (gmail)
2008-10-06 19:34 ` Lennart Borgman (gmail)
2008-10-06 19:35 ` Chong Yidong [this message]
2008-10-06 19:35 ` Chong Yidong
2008-10-06 21:28 ` Andreas Schwab
2008-10-07  2:09   ` bug#1082: " Stefan Monnier
2008-10-07  2:09   ` Stefan Monnier
2008-10-06 21:28 ` bug#1082: " Andreas Schwab
     [not found] ` <mailman.409.1223329803.25473.bug-gnu-emacs@gnu.org>
2008-10-06 22:17   ` Markus Triska

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87iqs5wm7z.fsf@cyd.mit.edu \
    --to=cyd@stupidchicken.com \
    --cc=1082@emacsbugs.donarmstrong.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.