aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/eshell/esh-proc.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/eshell/esh-proc.el')
-rw-r--r--lisp/eshell/esh-proc.el68
1 files changed, 33 insertions, 35 deletions
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el
index 99b43661f2c..c367b5cd643 100644
--- a/lisp/eshell/esh-proc.el
+++ b/lisp/eshell/esh-proc.el
@@ -346,7 +346,9 @@ Used only on systems which do not support async subprocesses.")
346 (defvar eshell-last-output-end) ;Defined in esh-mode.el. 346 (defvar eshell-last-output-end) ;Defined in esh-mode.el.
347 (eshell-update-markers eshell-last-output-end) 347 (eshell-update-markers eshell-last-output-end)
348 ;; Simulate the effect of eshell-sentinel. 348 ;; Simulate the effect of eshell-sentinel.
349 (eshell-close-handles (if (numberp exit-status) exit-status -1)) 349 (eshell-close-handles
350 (if (numberp exit-status) exit-status -1)
351 (list 'quote (and (numberp exit-status) (= exit-status 0))))
350 (eshell-kill-process-function command exit-status) 352 (eshell-kill-process-function command exit-status)
351 (or (bound-and-true-p eshell-in-pipeline-p) 353 (or (bound-and-true-p eshell-in-pipeline-p)
352 (setq eshell-last-sync-output-start nil)) 354 (setq eshell-last-sync-output-start nil))
@@ -398,40 +400,36 @@ PROC is the process that's exiting. STRING is the exit message."
398 (when (buffer-live-p (process-buffer proc)) 400 (when (buffer-live-p (process-buffer proc))
399 (with-current-buffer (process-buffer proc) 401 (with-current-buffer (process-buffer proc)
400 (unwind-protect 402 (unwind-protect
401 (let ((entry (assq proc eshell-process-list))) 403 (when-let ((entry (assq proc eshell-process-list)))
402; (if (not entry) 404 (unwind-protect
403; (error "Sentinel called for unowned process `%s'" 405 (unless (string= string "run")
404; (process-name proc)) 406 ;; Write the exit message if the status is
405 (when entry 407 ;; abnormal and the process is already writing
406 (unwind-protect 408 ;; to the terminal.
407 (progn 409 (when (and (eq proc (eshell-tail-process))
408 (unless (string= string "run") 410 (not (string-match "^\\(finished\\|exited\\)"
409 ;; Write the exit message if the status is 411 string)))
410 ;; abnormal and the process is already writing 412 (funcall (process-filter proc) proc string))
411 ;; to the terminal. 413 (let ((handles (nth 1 entry))
412 (when (and (eq proc (eshell-tail-process)) 414 (str (prog1 (nth 3 entry)
413 (not (string-match "^\\(finished\\|exited\\)" 415 (setf (nth 3 entry) nil)))
414 string))) 416 (status (process-exit-status proc)))
415 (funcall (process-filter proc) proc string)) 417 ;; If we're in the middle of handling output
416 (let ((handles (nth 1 entry)) 418 ;; from this process then schedule the EOF for
417 (str (prog1 (nth 3 entry) 419 ;; later.
418 (setf (nth 3 entry) nil))) 420 (letrec ((finish-io
419 (status (process-exit-status proc))) 421 (lambda ()
420 ;; If we're in the middle of handling output 422 (if (nth 4 entry)
421 ;; from this process then schedule the EOF for 423 (run-at-time 0 nil finish-io)
422 ;; later. 424 (when str
423 (letrec ((finish-io 425 (ignore-error 'eshell-pipe-broken
424 (lambda () 426 (eshell-output-object
425 (if (nth 4 entry) 427 str nil handles)))
426 (run-at-time 0 nil finish-io) 428 (eshell-close-handles
427 (when str 429 status (list 'quote (= status 0))
428 (ignore-error 'eshell-pipe-broken 430 handles)))))
429 (eshell-output-object 431 (funcall finish-io))))
430 str nil handles))) 432 (eshell-remove-process-entry entry)))
431 (eshell-close-handles
432 status 'nil handles)))))
433 (funcall finish-io)))))
434 (eshell-remove-process-entry entry))))
435 (eshell-kill-process-function proc string))))) 433 (eshell-kill-process-function proc string)))))
436 434
437(defun eshell-process-interact (func &optional all query) 435(defun eshell-process-interact (func &optional all query)