Function: eshell-close-handles
eshell-close-handles is a byte-compiled function defined in
esh-io.el.gz.
Signature
(eshell-close-handles &optional EXIT-CODE RESULT HANDLES)
Documentation
Close all of the current HANDLES, taking refcounts into account.
If HANDLES is nil, use eshell-current-handles.
EXIT-CODE is the process exit code (zero, if the command
completed successfully). If nil, then use the exit code already
set in eshell-last-command-status.
RESULT is the quoted value of the last command. If nil, then use
the value already set in eshell-last-command-result.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/esh-io.el.gz
(defun eshell-close-handles (&optional exit-code result handles)
"Close all of the current HANDLES, taking refcounts into account.
If HANDLES is nil, use `eshell-current-handles'.
EXIT-CODE is the process exit code (zero, if the command
completed successfully). If nil, then use the exit code already
set in `eshell-last-command-status'.
RESULT is the quoted value of the last command. If nil, then use
the value already set in `eshell-last-command-result'."
(when exit-code
(setq eshell-last-command-status exit-code))
(when result
(cl-assert (eq (car result) 'quote))
(setq eshell-last-command-result (cadr result)))
(let ((handles (or handles eshell-current-handles)))
(dotimes (idx eshell-number-of-handles)
(when-let ((handle (aref handles idx)))
(setcdr handle (1- (cdr handle)))
(when (= (cdr handle) 0)
(dolist (target (ensure-list (car (aref handles idx))))
(eshell-close-target target (= eshell-last-command-status 0)))
(setcar handle nil))))))