Function: pfuture--sentinel

pfuture--sentinel is a byte-compiled function defined in pfuture.el.

Signature

(pfuture--sentinel PROCESS _)

Documentation

Delete the stderr pipe process of PROCESS.

Source Code

;; Defined in ~/.emacs.d/elpa/pfuture-20220913.1401/pfuture.el
(defun pfuture--sentinel (process _)
  "Delete the stderr pipe process of PROCESS."
  (unless (process-live-p process)
    (let* ((stderr-process (process-get process 'stderr-process)))
      ;; Set stderr-process to nil so that await-to-finish does not delete
      ;; the buffer again.
      (process-put process 'stderr-process nil)
      ;; delete-process may trigger other sentinels. If there are many pfutures,
      ;; this will overflow the stack.
      (run-with-idle-timer 0 nil #'pfuture--delete-process stderr-process))
    ;; Make sure the stdout buffer is deleted even if the future
    ;; is never awaited
    (unless (process-get process 'result)
      (let* ((buffer (process-get process 'buffer))
             (result (with-current-buffer buffer (buffer-string))))
        (kill-buffer buffer)
        (process-put process 'result result)))))