From: Damien Kick
Subject: CMU CL: question about run-program
Date: 
Message-ID: <ovekzk2f4x.fsf@email.mot.com>
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.

    [····@csdndev08 kick/sparc-sun-solaris2.6]% cmucl
    CMU Common Lisp 18e, running on csdndev08
    With core: /usr/test/awo/user_work/kick/sparc-sun-solaris2.6/lib/cmucl/lib/lisp.core
    Dumped on: Tue, 2003-04-08 13:23:10-05:00 on achat
    See <http://www.cons.org/cmucl/> for support information.
    Loaded subsystems:
        Python 1.1, target SPARCstation/Solaris 2
        CLOS 18e (based on PCL September 16 92 PCL (f))
    * (progn
      (setq *p* (run-program "uname" nil :wait nil :pty t))
      (format t "(process-status *p*) => ~A~%" (process-status *p*))
      (setq *s* (process-pty *p*))
      (format t "(process-status *p*) => ~A~%" (process-status *p*))
      (read-char *s*)
      (format t "(process-status *p*) => ~A~%" (process-status *p*)))
    Warning:  Declaring *P* special.
    (process-status *p*) => RUNNING
    Warning:  Declaring *S* special.
    (process-status *p*) => RUNNING


    Error in function COMMON-LISP::DO-INPUT:
       Error reading #<Stream for descriptor 12>: I/O error

    Restarts:
      0: [ABORT] Return to Top-Level.

    Debug  (type H for help)

    (COMMON-LISP::DO-INPUT #<Stream for descriptor 12>)
    Source: Error finding source: 
    Error in function DEBUG::GET-FILE-TOP-LEVEL-FORM:  Source file no longer exists:
      target:code/fd-stream.lisp.
    0] 0
    * (process-close *p*)

    #<process 13942 :EXITED>
    * 

The following works as I would expect.

    * (run-program "uname" nil :output t)
    SunOS

    #<process 13960 :EXITED>
    * 

From: Rob Warnock
Subject: Re: CMU CL: question about run-program
Date: 
Message-ID: <h-KcnWApKaTklNyiXTWc-w@speakeasy.net>
Damien Kick  <······@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.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Damien Kick
Subject: Re: CMU CL: question about run-program
Date: 
Message-ID: <ovr83ilpcg.fsf@email.mot.com>
····@rpw3.org (Rob Warnock) writes:

> Damien Kick  <······@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:

The example in the OP does not actually need to be run in a
pseudo-terminal, as it is just collecting the result of "uname".
However, I'm more concerned with running programs that will want a
pseudo-terminal, e.g. controlling a telnet session.  I'm assuming that
simply using ":OUTPUT" and ":ERROR" do not have the program running in
a pseudo-terminal.
From: Rob Warnock
Subject: Re: CMU CL: question about run-program
Date: 
Message-ID: <kiKdnfBAiObnbdyiXTWc-g@speakeasy.net>
Damien Kick  <······@email.mot.com> wrote:
+---------------
| ····@rpw3.org (Rob Warnock) writes:
| > I've never managed to use :PTY for anything, but specifying the
| > options ":OUTPUT :STREAM" & ":ERROR :OUTPUT" usually works for me:
| 
| The example in the OP does not actually need to be run in a
| pseudo-terminal, as it is just collecting the result of "uname".
| However, I'm more concerned with running programs that will want a
| pseudo-terminal, e.g. controlling a telnet session.  I'm assuming that
| simply using ":OUTPUT" and ":ERROR" do not have the program running in
| a pseudo-terminal.
+---------------

Nope, just pipes.


-Rob

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