Subject: Re: 23.0.92; `accept-process-output' and `sleep-for' do not run sentinels

From: Stefan Monnier <[email-masked]>
Date: Mon, 17 Aug 2009 11:36:56 -0400

>> The documentation for sentinels states:
>> A program can wait, so that sentinels will run, by calling
>> `sit-for' or `sleep-for' (...), or `accept-process-output' (...).
>> 
>> However, when I do M-x eval-region RET on the following forms in
>> "emacs -Q", then Emacs loops unexpectedly:
>> 
>> (defun my-sentinel (proc str)
>> (setq my-finished t))
>> 
>> (let ((p (start-process "bc" nil "bc"))
>> my-finished)
>> (set-process-sentinel p 'my-sentinel)
>> (process-send-string p "quit\n")
>> (while (not my-finished)
>> (accept-process-output nil 0.1)))

> The trouble is that accept-process-output passes a zero DO_DISPLAY
> argument to wait_reading_process_output (process.c:4306).  When
> DO_DISPLAY is zero, status notifications are not performed
> (process.c:4763).

> Having accept-process-output pass a non-zero DO_DISPLAY argument to
> wait_reading_process_output fixes this problem, but I don't know what
> ramifications this would have.

I don't know.  You already changed it in that direction a year ago:

   timestamp: Mon 2008-05-19 22:29:33 +0000
   message:
     (wait_reading_process_output): Always check status when in batch mode.

so maybe we should change it even further?  I think a good change would
be to change the code of wait_reading_process_output such that status
changes are taken into account (even when do_display is 0) but only for
the process(es) for which we're waiting.

        Stefan