jwiegley / emacs-async

Simple library for asynchronous processing in Emacs
GNU General Public License v3.0
828 stars 68 forks source link

finish-func not called when process exits non-zero #101

Open alphapapa opened 6 years ago

alphapapa commented 6 years ago

Hi John,

Maybe I'm doing something wrong, but this doesn't seem right to me, and I can't find it documented anywhere (the lexical-let is because I ran that in *scratch*):

(progn
  (setq argh (async-start-process "ag-scan-async" "nice"
                                  (lexical-let ((start (format-time-string "%F %T")))
                                    (lambda (process)
                                      (message "STATUS: %s  STARTED AT: %s  CALLED AT: %s" (process-exit-status process)
                                               start (format-time-string "%F %T"))))
                                  "-n5"
                                  "timeout" "3"
                                  "sleep" "10"))
  (sleep-for 4)
  (list :ready (async-ready argh)
        :exit (process-exit-status argh)))

This sleeps for 4 seconds and returns:

(:ready t :exit 124)

However, message is never called. Then when I run:

(async-get argh)

I get:

(error "Async process 'ag-scan-async' failed with exit code 124")

This is inconvenient, because I'm trying to use timeout to prevent a process from running for too long, and I'd like to raise an error when it times out, but since the finish-func doesn't get called until I manually do async-get, I would have to run my own timer outside of async-start-process to catch it.

Thanks.