CMUCL does not support exit codes. Thus, an error is raised if the given code is...
[trivial-shell.git] / dev / openmcl.lisp
blobec6a8fbb2db52d5fd6631b0efec7c5badf44f6b5
1 (in-package #:trivial-shell)
3 (defun %shell-command (command input)
4 (let* ((process (create-shell-process command t input))
5 (output (file-to-string-as-lines
6 (ccl::external-process-output-stream process)))
7 (error (file-to-string-as-lines
8 (ccl::external-process-error-stream process))))
9 (close (ccl::external-process-output-stream process))
10 (close (ccl::external-process-error-stream process))
11 (values output
12 error
13 (process-exit-code process))))
15 (defun create-shell-process (command wait &optional input)
16 (with-input-from-string (input-stream input)
17 (ccl:run-program
18 *bourne-compatible-shell*
19 (list "-c" command)
20 :input input-stream :output :stream :error :stream
21 :wait wait)))
23 (defun process-alive-p (process)
24 (eq (nth-value 0 (ccl:external-process-status process)) :running))
26 (defun process-exit-code (process)
27 (nth-value 1 (ccl:external-process-status process)))
29 (defun %os-process-id ()
30 (error 'unsupported-function-error :function 'os-process-id))
32 (defun %get-env-var (name)
33 (ccl::getenv name))
35 (defun %exit (code)
36 (ccl:quit code))