* Re: Process sentinel not called in batch mode
@ 2008-05-13 23:28 Chong Yidong
2008-05-14 14:18 ` Stefan Monnier
0 siblings, 1 reply; 15+ messages in thread
From: Chong Yidong @ 2008-05-13 23:28 UTC (permalink / raw)
To: emacs-devel; +Cc: 141, Helmut Eller
Helmut Eller <eller.helmut@gmail.com> wrote:
> process-sentinels aren't called in batch mode. I'm not sure if this
> is a bug or the expected behavior, but I find this quite frustrating.
> To reproduce the problem do:
> $shell> cat test-sentinel.el
(defvar sentinel-called nil)
(defun main ()
(let ((proc (start-process "test" nil "bash" "-c" "sleep 1 ; exit 20")))
(set-process-sentinel proc (lambda (proc msg)
(message "sentinel: %S %s" proc msg)
(setq sentinel-called t)))
(while (not sentinel-called)
(message "status: %s exit-status: %s sentinel-called: %s"
(process-status proc) (process-exit-status proc)
sentinel-called)
(sit-for 1)
(accept-process-output proc 1))))
(main)
> $shell> emacs -Q -batch -l test-sentinel.el
This problem occurs because wait_reading_process_output only calls
status_notify when given a nonzero DO_DISPLAY argument (process.c:4451).
Although wait_reading_process_output is called from many places in
Emacs, it is given a nonzero DO_DISPLAY argument only during
kbd_buffer_get_event. But that function is never called in batch mode.
Maybe something like the attached patch should be applied.
Alternatively, we could change Faccept_process_output so that when Emacs
is in batch mode, it calls wait_reading_process_output with a nonzero
DO_DISPLAY argument. Opinions?
*** trunk/src/process.c.~1.539.~ 2008-04-09 13:46:04.000000000 -0400
--- trunk/src/process.c 2008-05-13 19:27:01.000000000 -0400
***************
*** 4414,4420 ****
available, notify the user of the change right away. After
this explicit check, we'll let the SIGCHLD handler zap
timeout to get our attention. */
! if (update_tick != process_tick && do_display)
{
SELECT_TYPE Atemp;
#ifdef NON_BLOCKING_CONNECT
--- 4414,4421 ----
available, notify the user of the change right away. After
this explicit check, we'll let the SIGCHLD handler zap
timeout to get our attention. */
! if (update_tick != process_tick
! && (do_display || noninteractive))
{
SELECT_TYPE Atemp;
#ifdef NON_BLOCKING_CONNECT
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: Process sentinel not called in batch mode
2008-05-13 23:28 Process sentinel not called in batch mode Chong Yidong
@ 2008-05-14 14:18 ` Stefan Monnier
2008-05-16 11:32 ` bug#141: " Richard M Stallman
0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2008-05-14 14:18 UTC (permalink / raw)
To: Chong Yidong; +Cc: 141, Helmut Eller, emacs-devel
> This problem occurs because wait_reading_process_output only calls
> status_notify when given a nonzero DO_DISPLAY argument (process.c:4451).
> Although wait_reading_process_output is called from many places in
> Emacs, it is given a nonzero DO_DISPLAY argument only during
> kbd_buffer_get_event. But that function is never called in batch mode.
Does anyone know why we test do_display there?
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-14 14:18 ` Stefan Monnier
@ 2008-05-16 11:32 ` Richard M Stallman
2008-05-16 13:25 ` Stefan Monnier
0 siblings, 1 reply; 15+ messages in thread
From: Richard M Stallman @ 2008-05-16 11:32 UTC (permalink / raw)
To: Stefan Monnier, 141
Cc: 141, cyd, eller.helmut, emacs-devel, bug-submit-list,
bug-gnu-emacs
> This problem occurs because wait_reading_process_output only calls
> status_notify when given a nonzero DO_DISPLAY argument (process.c:4451).
> Although wait_reading_process_output is called from many places in
> Emacs, it is given a nonzero DO_DISPLAY argument only during
> kbd_buffer_get_event. But that function is never called in batch mode.
Does anyone know why we test do_display there?
I think the idea is, if you are going to update the display, it is
good to display the fact that a process has terminated.
I don't claim this implies the code should not be changed.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-16 11:32 ` bug#141: " Richard M Stallman
@ 2008-05-16 13:25 ` Stefan Monnier
2008-05-16 14:41 ` Eli Zaretskii
0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2008-05-16 13:25 UTC (permalink / raw)
To: rms; +Cc: 141, cyd, eller.helmut, emacs-devel, bug-submit-list,
bug-gnu-emacs
>> This problem occurs because wait_reading_process_output only calls
>> status_notify when given a nonzero DO_DISPLAY argument (process.c:4451).
>> Although wait_reading_process_output is called from many places in
>> Emacs, it is given a nonzero DO_DISPLAY argument only during
>> kbd_buffer_get_event. But that function is never called in batch mode.
> Does anyone know why we test do_display there?
> I think the idea is, if you are going to update the display, it is
> good to display the fact that a process has terminated.
This side I understand, but what about the other: why should we not
check process status in the case where we are not redisplaying?
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-16 13:25 ` Stefan Monnier
@ 2008-05-16 14:41 ` Eli Zaretskii
2008-05-16 16:57 ` Stefan Monnier
0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2008-05-16 14:41 UTC (permalink / raw)
To: Stefan Monnier
Cc: 141, rms, cyd, eller.helmut, emacs-devel, bug-submit-list,
bug-gnu-emacs
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Date: Fri, 16 May 2008 09:25:54 -0400
> Cc: 141@emacsbugs.donarmstrong.com, cyd@stupidchicken.com,
> eller.helmut@gmail.com, emacs-devel@gnu.org,
> bug-submit-list@donarmstrong.com, bug-gnu-emacs@gnu.org
>
> >> This problem occurs because wait_reading_process_output only calls
> >> status_notify when given a nonzero DO_DISPLAY argument (process.c:4451).
> >> Although wait_reading_process_output is called from many places in
> >> Emacs, it is given a nonzero DO_DISPLAY argument only during
> >> kbd_buffer_get_event. But that function is never called in batch mode.
>
> > Does anyone know why we test do_display there?
>
> > I think the idea is, if you are going to update the display, it is
> > good to display the fact that a process has terminated.
>
> This side I understand, but what about the other: why should we not
> check process status in the case where we are not redisplaying?
Because Emacs generally looks at process output only when it's idle?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-16 14:41 ` Eli Zaretskii
@ 2008-05-16 16:57 ` Stefan Monnier
2008-05-16 17:23 ` Chong Yidong
2008-05-16 19:08 ` Eli Zaretskii
0 siblings, 2 replies; 15+ messages in thread
From: Stefan Monnier @ 2008-05-16 16:57 UTC (permalink / raw)
To: Eli Zaretskii
Cc: 141, rms, cyd, eller.helmut, emacs-devel, bug-submit-list,
bug-gnu-emacs
>> >> This problem occurs because wait_reading_process_output only calls
>> >> status_notify when given a nonzero DO_DISPLAY argument (process.c:4451).
>> >> Although wait_reading_process_output is called from many places in
>> >> Emacs, it is given a nonzero DO_DISPLAY argument only during
>> >> kbd_buffer_get_event. But that function is never called in batch mode.
>>
>> > Does anyone know why we test do_display there?
>>
>> > I think the idea is, if you are going to update the display, it is
>> > good to display the fact that a process has terminated.
>>
>> This side I understand, but what about the other: why should we not
>> check process status in the case where we are not redisplaying?
> Because Emacs generally looks at process output only when it's idle?
I don't follow: we're talking about when should
wait_reading_process_output check status_notify.
So to repeat/rephrase my question: why doesn't
wait_reading_process_output call status_notify when it is passed a zero
do_display?
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-16 16:57 ` Stefan Monnier
@ 2008-05-16 17:23 ` Chong Yidong
2008-05-16 19:08 ` Eli Zaretskii
1 sibling, 0 replies; 15+ messages in thread
From: Chong Yidong @ 2008-05-16 17:23 UTC (permalink / raw)
To: Stefan Monnier
Cc: 141, rms, bug-gnu-emacs, eller.helmut, emacs-devel, Eli Zaretskii,
bug-submit-list
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> So to repeat/rephrase my question: why doesn't
> wait_reading_process_output call status_notify when it is passed a
> zero do_display?
I don't see any good reason, but the current behavior seems to work OK
for !noninteractive.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-16 16:57 ` Stefan Monnier
2008-05-16 17:23 ` Chong Yidong
@ 2008-05-16 19:08 ` Eli Zaretskii
2008-05-16 19:24 ` Stefan Monnier
1 sibling, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2008-05-16 19:08 UTC (permalink / raw)
To: Stefan Monnier
Cc: 141, rms, cyd, eller.helmut, emacs-devel, bug-submit-list,
bug-gnu-emacs
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: rms@gnu.org, 141@emacsbugs.donarmstrong.com, cyd@stupidchicken.com, eller.helmut@gmail.com, emacs-devel@gnu.org, bug-submit-list@donarmstrong.com, bug-gnu-emacs@gnu.org
> Date: Fri, 16 May 2008 12:57:16 -0400
>
> >> This side I understand, but what about the other: why should we not
> >> check process status in the case where we are not redisplaying?
>
> > Because Emacs generally looks at process output only when it's idle?
>
> I don't follow: we're talking about when should
> wait_reading_process_output check status_notify.
>
> So to repeat/rephrase my question: why doesn't
> wait_reading_process_output call status_notify when it is passed a zero
> do_display?
Sorry, let me explain my line of thought in more detail: Emacs only
does a redisplay when it is idle. Emacs also checks input from
subprocesses when it is idle. If we are not in redisplay, it means
Emacs is not idle, and so it makes sense not to check for subprocess
output at that time.
Does this make any sense?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-16 19:08 ` Eli Zaretskii
@ 2008-05-16 19:24 ` Stefan Monnier
2008-05-16 20:07 ` Eli Zaretskii
2008-05-16 20:58 ` David Kastrup
0 siblings, 2 replies; 15+ messages in thread
From: Stefan Monnier @ 2008-05-16 19:24 UTC (permalink / raw)
To: Eli Zaretskii
Cc: 141, rms, cyd, eller.helmut, emacs-devel, bug-submit-list,
bug-gnu-emacs
>> >> This side I understand, but what about the other: why should we not
>> >> check process status in the case where we are not redisplaying?
>>
>> > Because Emacs generally looks at process output only when it's idle?
>>
>> I don't follow: we're talking about when should
>> wait_reading_process_output check status_notify.
>>
>> So to repeat/rephrase my question: why doesn't
>> wait_reading_process_output call status_notify when it is passed a zero
>> do_display?
> Sorry, let me explain my line of thought in more detail: Emacs only
> does a redisplay when it is idle. Emacs also checks input from
> subprocesses when it is idle. If we are not in redisplay, it means
> Emacs is not idle, and so it makes sense not to check for subprocess
> output at that time.
> Does this make any sense?
But if we're in wait_reading_process_output, that means that idle or
not, we're checking for process output, so why not check for process
status changes as well?
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-16 19:24 ` Stefan Monnier
@ 2008-05-16 20:07 ` Eli Zaretskii
2008-05-18 3:45 ` Stefan Monnier
2008-05-16 20:58 ` David Kastrup
1 sibling, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2008-05-16 20:07 UTC (permalink / raw)
To: Stefan Monnier
Cc: 141, rms, cyd, eller.helmut, emacs-devel, bug-submit-list,
bug-gnu-emacs
> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: rms@gnu.org, 141@emacsbugs.donarmstrong.com, cyd@stupidchicken.com, eller.helmut@gmail.com, emacs-devel@gnu.org, bug-submit-list@donarmstrong.com, bug-gnu-emacs@gnu.org
> Date: Fri, 16 May 2008 15:24:04 -0400
>
> >> >> This side I understand, but what about the other: why should we not
> >> >> check process status in the case where we are not redisplaying?
> >>
> >> > Because Emacs generally looks at process output only when it's idle?
> >>
> >> I don't follow: we're talking about when should
> >> wait_reading_process_output check status_notify.
> >>
> >> So to repeat/rephrase my question: why doesn't
> >> wait_reading_process_output call status_notify when it is passed a zero
> >> do_display?
>
> > Sorry, let me explain my line of thought in more detail: Emacs only
> > does a redisplay when it is idle. Emacs also checks input from
> > subprocesses when it is idle. If we are not in redisplay, it means
> > Emacs is not idle, and so it makes sense not to check for subprocess
> > output at that time.
>
> > Does this make any sense?
>
> But if we're in wait_reading_process_output, that means that idle or
> not, we're checking for process output, so why not check for process
> status changes as well?
Because status_notify has a side effect of triggering redisplay.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-16 19:24 ` Stefan Monnier
2008-05-16 20:07 ` Eli Zaretskii
@ 2008-05-16 20:58 ` David Kastrup
1 sibling, 0 replies; 15+ messages in thread
From: David Kastrup @ 2008-05-16 20:58 UTC (permalink / raw)
To: Stefan Monnier
Cc: 141, rms, cyd, eller.helmut, emacs-devel, Eli Zaretskii,
bug-submit-list, bug-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> But if we're in wait_reading_process_output, that means that idle or
> not, we're checking for process output, so why not check for process
> status changes as well?
Because we want to have all process output processed before registering
that the process has finished?
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-16 20:07 ` Eli Zaretskii
@ 2008-05-18 3:45 ` Stefan Monnier
2008-05-19 3:00 ` Chong Yidong
0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2008-05-18 3:45 UTC (permalink / raw)
To: Eli Zaretskii
Cc: 141, rms, cyd, eller.helmut, emacs-devel, bug-submit-list,
bug-gnu-emacs
>> >> >> This side I understand, but what about the other: why should we not
>> >> >> check process status in the case where we are not redisplaying?
>> >>
>> >> > Because Emacs generally looks at process output only when it's idle?
>> >>
>> >> I don't follow: we're talking about when should
>> >> wait_reading_process_output check status_notify.
>> >>
>> >> So to repeat/rephrase my question: why doesn't
>> >> wait_reading_process_output call status_notify when it is passed a zero
>> >> do_display?
>>
>> > Sorry, let me explain my line of thought in more detail: Emacs only
>> > does a redisplay when it is idle. Emacs also checks input from
>> > subprocesses when it is idle. If we are not in redisplay, it means
>> > Emacs is not idle, and so it makes sense not to check for subprocess
>> > output at that time.
>>
>> > Does this make any sense?
>>
>> But if we're in wait_reading_process_output, that means that idle or
>> not, we're checking for process output, so why not check for process
>> status changes as well?
> Because status_notify has a side effect of triggering redisplay.
Thanks. Now it makes a lot more sense. Please add a corresponding
comment on the do_display check.
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-18 3:45 ` Stefan Monnier
@ 2008-05-19 3:00 ` Chong Yidong
2008-05-19 8:24 ` Stefan Monnier
0 siblings, 1 reply; 15+ messages in thread
From: Chong Yidong @ 2008-05-19 3:00 UTC (permalink / raw)
To: Stefan Monnier
Cc: 141, rms, bug-gnu-emacs, eller.helmut, emacs-devel, Eli Zaretskii,
bug-submit-list
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> But if we're in wait_reading_process_output, that means that idle or
>>> not, we're checking for process output, so why not check for process
>>> status changes as well?
>
>> Because status_notify has a side effect of triggering redisplay.
>
> Thanks. Now it makes a lot more sense. Please add a corresponding
> comment on the do_display check.
What do you think should be the fix for the original problem?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-19 3:00 ` Chong Yidong
@ 2008-05-19 8:24 ` Stefan Monnier
2008-05-19 16:26 ` Chong Yidong
0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2008-05-19 8:24 UTC (permalink / raw)
To: Chong Yidong
Cc: 141, rms, bug-gnu-emacs, eller.helmut, emacs-devel, Eli Zaretskii,
bug-submit-list
>>>> But if we're in wait_reading_process_output, that means that idle or
>>>> not, we're checking for process output, so why not check for process
>>>> status changes as well?
>>
>>> Because status_notify has a side effect of triggering redisplay.
>>
>> Thanks. Now it makes a lot more sense. Please add a corresponding
>> comment on the do_display check.
> What do you think should be the fix for the original problem?
The one you proposed seems right,
Stefan
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: bug#141: Process sentinel not called in batch mode
2008-05-19 8:24 ` Stefan Monnier
@ 2008-05-19 16:26 ` Chong Yidong
0 siblings, 0 replies; 15+ messages in thread
From: Chong Yidong @ 2008-05-19 16:26 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 141-done, Eli Zaretskii, eller.helmut, rms, emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>>>> But if we're in wait_reading_process_output, that means that idle or
>>>>> not, we're checking for process output, so why not check for process
>>>>> status changes as well?
>>>
>>>> Because status_notify has a side effect of triggering redisplay.
>>>
>>> Thanks. Now it makes a lot more sense. Please add a corresponding
>>> comment on the do_display check.
>
>> What do you think should be the fix for the original problem?
>
> The one you proposed seems right,
OK. I've checked it in.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2008-05-19 16:26 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-13 23:28 Process sentinel not called in batch mode Chong Yidong
2008-05-14 14:18 ` Stefan Monnier
2008-05-16 11:32 ` bug#141: " Richard M Stallman
2008-05-16 13:25 ` Stefan Monnier
2008-05-16 14:41 ` Eli Zaretskii
2008-05-16 16:57 ` Stefan Monnier
2008-05-16 17:23 ` Chong Yidong
2008-05-16 19:08 ` Eli Zaretskii
2008-05-16 19:24 ` Stefan Monnier
2008-05-16 20:07 ` Eli Zaretskii
2008-05-18 3:45 ` Stefan Monnier
2008-05-19 3:00 ` Chong Yidong
2008-05-19 8:24 ` Stefan Monnier
2008-05-19 16:26 ` Chong Yidong
2008-05-16 20:58 ` David Kastrup
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).