Function: eshell-close-handles
eshell-close-handles is a byte-compiled function defined in
esh-io.el.gz.
Signature
(eshell-close-handles EXIT-CODE &optional RESULT HANDLES)
Documentation
Close all of the current handles, taking refcounts into account.
EXIT-CODE is the process exit code; mainly, it is zero, if the command completed successfully. RESULT is the quoted value of the last command. If nil, then the meta variables for keeping track of the last execution result should not be changed.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/esh-io.el.gz
(defun eshell-close-handles (exit-code &optional result handles)
"Close all of the current handles, taking refcounts into account.
EXIT-CODE is the process exit code; mainly, it is zero, if the command
completed successfully. RESULT is the quoted value of the last
command. If nil, then the meta variables for keeping track of the
last execution result should not be changed."
(let ((idx 0))
(cl-assert (or (not result) (eq (car result) 'quote)))
(setq eshell-last-command-status exit-code
eshell-last-command-result (cadr result))
(while (< idx eshell-number-of-handles)
(let ((handles (or handles eshell-current-handles)))
(when (aref handles idx)
(setcdr (aref handles idx)
(1- (cdr (aref handles idx))))
(when (= (cdr (aref handles idx)) 0)
(let ((target (car (aref handles idx))))
(if (not (listp target))
(eshell-close-target target (= exit-code 0))
(while target
(eshell-close-target (car target) (= exit-code 0))
(setq target (cdr target)))))
(setcar (aref handles idx) nil))))
(setq idx (1+ idx)))
nil))