unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: emacs-devel@gnu.org
Cc: 141@emacsbugs.donarmstrong.com, Helmut Eller <eller.helmut@gmail.com>
Subject: Re: Process sentinel not called in batch mode
Date: Tue, 13 May 2008 19:28:04 -0400	[thread overview]
Message-ID: <87hcd1kcmz.fsf@stupidchicken.com> (raw)

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




             reply	other threads:[~2008-05-13 23:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-13 23:28 Chong Yidong [this message]
2008-05-14 14:18 ` Process sentinel not called in batch mode 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

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87hcd1kcmz.fsf@stupidchicken.com \
    --to=cyd@stupidchicken.com \
    --cc=141@emacsbugs.donarmstrong.com \
    --cc=eller.helmut@gmail.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 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).