emacs-devel
[Top][All Lists]
Advanced

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

Re: 23.0.60; read-char unexpectedly halts execution of script


From: Chong Yidong
Subject: Re: 23.0.60; read-char unexpectedly halts execution of script
Date: Mon, 06 Oct 2008 15:35:28 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Chong Yidong <address@hidden> 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);
}




reply via email to

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