all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: Process sentinel not called in batch mode
@ 2008-05-13 23:28 Chong Yidong
  2008-05-14 14:18 ` bug#141: " Stefan Monnier
  2008-05-14 14:18 ` Stefan Monnier
  0 siblings, 2 replies; 19+ 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] 19+ messages in thread
* bug#141: Process sentinel not called in batch mode
@ 2008-05-13 23:28 Chong Yidong
  0 siblings, 0 replies; 19+ 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] 19+ messages in thread

end of thread, other threads:[~2008-05-19 16:40 UTC | newest]

Thread overview: 19+ 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 ` bug#141: " Stefan Monnier
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-04-15 14:48                         ` Helmut Eller
2008-05-19 16:40                           ` bug#141: marked as done (Process sentinel not called in batch mode) Emacs bug Tracking System
2008-05-16 20:58               ` bug#141: Process sentinel not called in batch mode David Kastrup
  -- strict thread matches above, loose matches on Subject: below --
2008-05-13 23:28 Chong Yidong

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.