branch: externals/buffer-env
commit a15b608a3ef14db902803405f792b13f367ed24d
Author: Augusto Stoffel <arstof...@gmail.com>
Commit: Augusto Stoffel <arstof...@gmail.com>

    Avoid race condition when reading process output
    
    Fixes #22.
---
 buffer-env.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/buffer-env.el b/buffer-env.el
index ba5bfa4b1a..dcc0dcd711 100644
--- a/buffer-env.el
+++ b/buffer-env.el
@@ -212,8 +212,11 @@ When called interactively, ask for a FILE."
                                        :sentinel #'ignore
                                        :buffer (current-buffer)
                                        :stderr errbuf)))
+                           ;; Give subprocess a chance to finish
+                           ;; before setting up a progress reporter
                            (sit-for 0)
-                           (when (process-live-p proc)
+                           (if (not (process-live-p proc))
+                               (accept-process-output proc)
                              (let* ((msg (format-message "[buffer-env] Running 
`%s'..." file))
                                     (reporter (make-progress-reporter msg)))
                                (while (or (accept-process-output proc 1)

Reply via email to