Function: eshell-duplicate-handles
eshell-duplicate-handles is a byte-compiled function defined in
esh-io.el.gz.
Signature
(eshell-duplicate-handles HANDLES &optional STEAL-P)
Documentation
Create a duplicate of the file handles in HANDLES.
This uses the targets of each handle in HANDLES, incrementing its
reference count by one (unless STEAL-P is non-nil). These
targets are shared between the original set of handles and the
new one, so the targets are only closed when the reference count
drops to 0 (see eshell-close-handles).
This function also sets the DEFAULT field for each handle to
t (see eshell-create-handles). Unlike the targets, this value
is not shared with the original handles.
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/esh-io.el.gz
(defun eshell-duplicate-handles (handles &optional steal-p)
"Create a duplicate of the file handles in HANDLES.
This uses the targets of each handle in HANDLES, incrementing its
reference count by one (unless STEAL-P is non-nil). These
targets are shared between the original set of handles and the
new one, so the targets are only closed when the reference count
drops to 0 (see `eshell-close-handles').
This function also sets the DEFAULT field for each handle to
t (see `eshell-create-handles'). Unlike the targets, this value
is not shared with the original handles."
(let ((dup-handles (make-vector eshell-number-of-handles nil)))
(dotimes (idx eshell-number-of-handles)
(when-let ((handle (aref handles idx)))
(unless steal-p
(cl-incf (cdar handle)))
(aset dup-handles idx (list (car handle) t))))
dup-handles))