]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't do anything in 'eshell-sentinel' if the process status is "run"
authorJim Porter <jporterbugs@gmail.com>
Fri, 18 Aug 2023 05:40:03 +0000 (22:40 -0700)
committerJim Porter <jporterbugs@gmail.com>
Tue, 12 Sep 2023 18:44:27 +0000 (11:44 -0700)
This doesn't change anything right now, but it will prevent future
issues when we add the ability to resume suspended processes in
Eshell.

* lisp/eshell/esh-proc.el (eshell-sentinel): Check for "run" status
earlier.

lisp/eshell/esh-proc.el

index 05ee18401af86e31130249e1f57dc7cc5a5e2b48..50f8c026fabff840ec91e0af1363097b57738276 100644 (file)
@@ -485,44 +485,44 @@ PROC is the process that's exiting.  STRING is the exit message."
   (eshell-debug-command
    'process (format-message "sentinel for external process `%s': %S"
                             proc string))
-  (when (buffer-live-p (process-buffer proc))
+  (when (and (buffer-live-p (process-buffer proc))
+             (not (string= string "run")))
     (with-current-buffer (process-buffer proc)
       (unwind-protect
-          (unless (string= string "run")
+          (let* ((handles (process-get proc :eshell-handles))
+                 (index (process-get proc :eshell-handle-index))
+                 (data (process-get proc :eshell-pending))
+                 ;; Only get the status for the primary subprocess,
+                 ;; not the pipe process (if any).
+                 (status (when (= index eshell-output-handle)
+                           (process-exit-status proc))))
             ;; Write the exit message if the status is abnormal and
             ;; the process is already writing to the terminal.
             (when (and (eq proc (eshell-tail-process))
                        (not (string-match "^\\(finished\\|exited\\)"
                                           string)))
               (funcall (process-filter proc) proc string))
-            (let* ((handles (process-get proc :eshell-handles))
-                   (index (process-get proc :eshell-handle-index))
-                   (data (process-get proc :eshell-pending))
-                   ;; Only get the status for the primary subprocess,
-                   ;; not the pipe process (if any).
-                   (status (when (= index eshell-output-handle)
-                            (process-exit-status proc))))
-              (process-put proc :eshell-pending nil)
-              ;; If we're in the middle of handling output from this
-              ;; process then schedule the EOF for later.
-              (letrec ((finish-io
-                        (lambda ()
-                          (if (process-get proc :eshell-busy)
-                              (run-at-time 0 nil finish-io)
-                            (when data
-                              (ignore-error eshell-pipe-broken
-                                (eshell-output-object
-                                 data index handles)))
-                            (eshell-close-handles
-                             status
-                             (when status (list 'quote (= status 0)))
-                             handles)
-                            (eshell-kill-process-function proc string)
+            (process-put proc :eshell-pending nil)
+            ;; If we're in the middle of handling output from this
+            ;; process then schedule the EOF for later.
+            (letrec ((finish-io
+                      (lambda ()
+                        (if (process-get proc :eshell-busy)
+                            (run-at-time 0 nil finish-io)
+                          (when data
+                            (ignore-error eshell-pipe-broken
+                              (eshell-output-object
+                               data index handles)))
+                          (eshell-close-handles
+                           status
+                           (when status (list 'quote (= status 0)))
+                           handles)
+                          (eshell-kill-process-function proc string)
                             (eshell-debug-command
                              'process
                              (format-message
                               "finished external process `%s'" proc))))))
-                (funcall finish-io))))
+              (funcall finish-io)))
         (when-let ((entry (assq proc eshell-process-list)))
           (eshell-remove-process-entry entry))))))