(defparameter *shell* (uiop:launch-program "zsh" :input :stream :output :stream)) (defconst +buffer-size+ 1024) (defvar *buff* (make-array +buffer-size+ :initial-element nil )) (define-symbol-macro *output* (uiop:process-info-output *shell*)) (define-symbol-macro *input* (uiop:process-info-input *shell*)) (write-line "ps" (uiop:process-info-input *shell*)) (force-output (uiop:process-info-input *shell*)) (time (read-line *output*) (read-sequence *buff* (uiop:process-info-output *shell*)) (defun read-output (&key (program *shell*) (to-string nil)) (flet ((output () (let ((stream (uiop:process-info-output program)) (first t)) (loop while (or first (listen stream)) do (setf first nil) (princ (read-line stream)) (fresh-line))))) (if to-string (read-output-string (output)) (output)))) (defun exec (command &optional to-string) (write-line command (uiop:process-info-input *shell*)) (force-output (process-info-input *shell*)) (read-output :to-string to-string))