Function: eshell-sentinel

eshell-sentinel is a byte-compiled function defined in esh-proc.el.gz.

Signature

(eshell-sentinel PROC STRING)

Documentation

Generic sentinel for command processes. Reports only signals.

PROC is the process that's exiting. STRING is the exit message.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-proc.el.gz
(defun eshell-sentinel (proc string)
  "Generic sentinel for command processes.  Reports only signals.
PROC is the process that's exiting.  STRING is the exit message."
  (when (buffer-live-p (process-buffer proc))
    (with-current-buffer (process-buffer proc)
      (unwind-protect
	  (let* ((entry (assq proc eshell-process-list)))
;	    (if (not entry)
;		(error "Sentinel called for unowned process `%s'"
;		       (process-name proc))
	    (when entry
	      (unwind-protect
		  (progn
		    (unless (string= string "run")
		      (unless (string-match "^\\(finished\\|exited\\)" string)
			(eshell-insertion-filter proc string))
                      (let ((handles (nth 1 entry))
                            (str (prog1 (nth 3 entry)
                                   (setf (nth 3 entry) nil)))
                            (status (process-exit-status proc)))
                        ;; If we're in the middle of handling output
                        ;; from this process then schedule the EOF for
                        ;; later.
                        (letrec ((finish-io
                                  (lambda ()
                                    (if (nth 4 entry)
                                        (run-at-time 0 nil finish-io)
                                      (when str (eshell-output-object str nil handles))
                                      (eshell-close-handles status 'nil handles)))))
                          (funcall finish-io)))))
		(eshell-remove-process-entry entry))))
	(eshell-kill-process-function proc string)))))