Subject: Re: CMU CL: question about run-program
From: rpw3@rpw3.org (Rob Warnock)
Date: Mon, 18 Aug 2003 12:14:33 -0500
Newsgroups: comp.lang.lisp
Message-ID: <h-KcnWApKaTklNyiXTWc-w@speakeasy.net>
Damien Kick  <dkick1@email.mot.com> wrote:
+---------------
| I don't understand why the following example is encountering an error
| attempting to READ-CHAR from the stream returned calling PROCESS-PTY
| on the result of RUN-PROGRAM.
...
|     CMU Common Lisp 18e, running on csdndev08
|     * (progn
|         (setq *p* (run-program "uname" nil :wait nil :pty t))
|         ... )
+---------------

I've never managed to use :PTY for anything, but specifying the
options ":OUTPUT :STREAM" & ":ERROR :OUTPUT" usually works for me:

	> (let ((p (run-program "uname" nil :wait nil
			        :output :stream :error :output)))
	    (dbgv (here)		; handy little debugging macro
	      p
	      (process-status p) 
	      (process-output p) 
	      (process-error p) 
	      (read-line (process-output p) nil nil)
	      (read-line (process-output p) nil nil) 
	      (process-status p) 
	      (process-close p)))

	DBGV: @HERE:
	P = #<process 87939 :RUNNING>
	(PROCESS-STATUS P) = :RUNNING
	(PROCESS-OUTPUT P) = #<Stream for descriptor 8>
	(PROCESS-ERROR P) = #<Stream for descriptor 8>
	(READ-LINE (PROCESS-OUTPUT P) NIL NIL) = "FreeBSD"
	(READ-LINE (PROCESS-OUTPUT P) NIL NIL) = NIL
	(PROCESS-STATUS P) = :EXITED
	(PROCESS-CLOSE P) = #<process 87939 :EXITED>
	NIL
	> 

[Note: Without the second READ-LINE it doesn't see that it's exited.]


-Rob

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607