Function: ghostel--spawn-via-native

ghostel--spawn-via-native is a natively compiled function defined in ghostel.el.

Signature

(ghostel--spawn-via-native COMMAND)

Documentation

Spawn COMMAND through the native PTY implementation.

COMMAND is a list of argv strings. Returns the event pipe process used as the Emacs-side handle for the native child process. The native reader writes terminal events to the pipe, and its detached reaper writes a final exit status before closing it.

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--spawn-via-native (command)
  "Spawn COMMAND through the native PTY implementation.
COMMAND is a list of argv strings.  Returns the event pipe process used
as the Emacs-side handle for the native child process.  The native
reader writes terminal events to the pipe, and its detached reaper
writes a final exit status before closing it."
  (let* ((pipe (make-pipe-process
                :name "ghostel-native-process"
                :buffer (current-buffer)
                :filter #'ghostel--events-filter
                :noquery t))
         (pid (ghostel--spawn-native-process ghostel--term command pipe)))
    (setq ghostel--pid pid)
    (process-put pipe 'ghostel--native-pid pid)

    (set-process-sentinel pipe
                          (lambda (process event)
                            ;; The pipe stands in for the native child process.
                            ;; If Emacs deletes it before normal exit, make sure
                            ;; the child is not left running.  After normal exit
                            ;; the reaper has already waited, so this is a no-op.
                            (signal-process
                             (process-get process 'ghostel--native-pid) 9)
                            (ghostel--sentinel process event)))
    (add-hook 'kill-buffer-hook #'ghostel--kill-native-process-hook nil t)
    pipe))