From: ·······@ziplip.com
Subject: (CMU CL) : RUN-PROGRAM bug
Date: 
Message-ID: <JTOCKGCJLUB0NUH4L1NXMNKCNRCDINFQP3DYN3EC@ziplip.com>
I think programs should return an integer, not just :EXITED
Some UNIX programs rely on this to be able to tell others if 
they were successful.

From: Damien Kick
Subject: Re: (CMU CL) : RUN-PROGRAM bug
Date: 
Message-ID: <ovada73ffw.fsf@email.mot.com>
········@ziplip.com" <·······@ziplip.com> writes:

> I think programs should return an integer, not just :EXITED
> Some UNIX programs rely on this to be able to tell others if 
> they were successful.

A slightly extended example:

    * 
    (let ((process (run-program "uname" nil :wait nil :output t)))
      (unwind-protect
           nil
        (let ((status (process-status process)))
          (format t "status => ~A~%" status)
          (unless (eql status :running)
            (format t "(process-exit-code process) => ~A~%"
                    (process-exit-code process)))
          (format t "(process-close process) => ~A~%"
                  (process-close process)))))
    status => RUNNING
    (process-close process) => #<process 14561 :RUNNING>
    NIL
    * SunOS

    nil

    NIL
    * 
    (let ((process (run-program "uname" nil :wait nil :pty t)))
      (unwind-protect
           (let ((stream (process-pty process)))
             (format t "Before attempting to read-char")
             (force-output)
             (format t "(read-char stream) => ~A~%"
                     (read-char stream)))
        (progn
          (format t "(process-status process) => ~A~%"
                  (process-status process))
          (format t "(process-exit-code process) => ~A~%"
                  (process-exit-code process))
          (format t "(process-close process) => ~A~%"
                  (process-close process)))))
    Before attempting to read-char


    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-status process) => EXITED
    (process-exit-code process) => 0
    (process-close process) => #<process 14569 :EXITED>
    * 
From: Eric Marsden
Subject: Re: (CMU CL) : RUN-PROGRAM bug
Date: 
Message-ID: <wzismnnaypd.fsf@melbourne.laas.fr>
>>>>> "dk" == Damien Kick <······@email.mot.com> writes:

  dk> (let ((process (run-program "uname" nil :wait nil :pty t)))

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

in order to use the :pty option to RUN-PROGRAM, you should also
specify the options

   :input t :output t :error t

The reason for this is somewhat obscure: the default values for these
options mean that a descriptor is allocated from /dev/null, which ends
up squashing (via dup2) the descriptor for the slave side of the tty
in the child, which means that you get an EIO when attempting to read
from the parent.

The defaults should really be set more intelligently in this case.
   
-- 
Eric Marsden                          <URL:http://www.laas.fr/~emarsden/>
From: Damien Kick
Subject: Re: (CMU CL) : RUN-PROGRAM bug
Date: 
Message-ID: <ovu17vyu5o.fsf@email.mot.com>
Eric Marsden <········@laas.fr> writes:

> >>>>> "dk" == Damien Kick <······@email.mot.com> writes:
> 
>   dk> (let ((process (run-program "uname" nil :wait nil :pty t)))
> 
>   dk> Error in function COMMON-LISP::DO-INPUT:
>   dk> Error reading #<Stream for descriptor 12>: I/O error
> 
> in order to use the :pty option to RUN-PROGRAM, you should also
> specify the options
> 
>    :input t :output t :error t

Thank you very much.  FWIW, now I have an ILISP question/problem <grin
type="sheepish">.  Everything works just great if I run things from
the UNIX shell.

    [····@csdndev08 ~/tmp]% 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))
    * (let ((process (ext:run-program "uname" nil :wait nil :pty t
                                      :input t :output t :error t)))
      (unwind-protect
           (let ((stream (ext:process-pty process)))
             (format t "Before attempting to read-char ")
             (force-output)
             (format t "(read-char stream) => ~A~%"
                     (read-char stream)))
        (progn
          (format t "(process-status process) => ~A~%"
                  (ext:process-status process))
          (format t "(process-exit-code process) => ~A~%"
                  (ext:process-exit-code process))
          (format t "(process-close process) => ~A~%"
                  (ext:process-close process)))))
    Before attempting to read-char (read-char stream) => S
    (process-status process) => RUNNING
    (process-exit-code process) => NIL
    (process-close process) => #<process 20369 :EXITED>
    NIL
    * 

However, if I try the same thing within an ILISP buffer, I have
problems.

    ;; ilisp-*version* => 5.12.0
    * 
    (let ((process (ext:run-program "uname" nil :wait nil :pty t
                                    :input t :output t :error t)))
      #| ... |#)
    Before attempting to read-char (read-char stream) => S
    (process-status process) => RUNNING
    (process-exit-code process) => NIL
    ;; At this point, the *cmulisp* buffer process has died...

I don't have the same problem without the :PTY keyword, though...

    * (let ((process (ext:run-program "uname" nil :wait nil :output t)))
      (unwind-protect
           nil
        (let ((status (ext:process-status process)))
          (format t "status => ~A~%" status)
          (unless (eql status :running)
            (format t "(process-exit-code process) => ~A~%"
                    (ext:process-exit-code process)))
          (format t "(process-close process) => ~A~%"
                  (ext:process-close process)))))
    status => RUNNING
    (process-close process) => #<process 20580 :RUNNING>
    NIL
    * SunOS
    ;; Everything is still happy...

I haven't found any mention of RUN-PROGRAM in the ILISP bug tracker
<http://sourceforge.net/tracker/?group_id=3957&atid=103957> or mailing
lists <http://sourceforge.net/mail/?group_id=3957> but we'll see what
they have to say about it.
From: Eduardo Muñoz
Subject: Re: (CMU CL) : RUN-PROGRAM bug
Date: 
Message-ID: <u65kvgama.fsf@terra.es>
* ········@ziplip.com" <·······@ziplip.com>
| I think programs should return an integer, not just :EXITED
| Some UNIX programs rely on this to be able to tell others if 
| they were successful.

* (RUN-PROGRAM "ls" '("-la") :wait nil :output t)
#<process 18002 :RUNNING>
* total 85
drwxr-xr-x   16 root     root         4096 Jul  8 18:24 .
drwxr-xr-x   16 root     root         4096 Jul  8 18:24 ..
<snip>

* (process-exit-code *)
0
* (RUN-PROGRAM "ls" '("-la" "/root") :wait nil :output t)
#<process 18003 :RUNNING>
* ls: /root/.: Permission denied
ls: /root/..: Permission denied
ls: /root/.bash_history: Permission denied
<snip>
total 0
* (process-exit-code *)
1
* 

HTH

-- 
Eduardo Mu�oz          | (prog () 10 (print "Hello world!")
http://213.97.131.125/ |          20 (go 10))