[Openmcl-devel] External process i/o weirdness?

Gary Byers gb at clozure.com
Wed May 14 14:52:50 UTC 2003



On Wed, 14 May 2003, Michael Klingbeil wrote:

> I'm having some trouble sending data to an external process created
> via ccl:run-program. If I understand the documentation correctly if I
> pass :stream as the input option, then I should be able to write to a
> stream which will serve as the input feeding the external process.
>
> However, whenever I try to write to this stream, I get errors. In
> fact as I experiment further is sort of looks like the input and
> output streams are double reversed -- the data structures for input
> and output are reversed but the file descriptors are also reversed --
> so nothing works! But there might be something I am totally missing.
>
> I am using openmcl 0.13.5 under Darwin (MacOS X 10.2.4). I am
> including a transcript of my experiments.
>
>
> Michael

One thing that's pretty scary in the output below is that a lot of
the file descriptor-based streams are printing out as

     #<FD-CHARACTER-INPUT-STREAM (NIL/4) #x566423E>
                                  ^^^
Instead of NIL/4, I'd kind of expect to see :PIPE/4, or :FILE/4; I think
we're looking at streams whose FD has been closed (deliberately but
mistakenly.)  The issue of which is input (to what) and which is output
certainly matters, but it doesn't look like we could do any I/O to either
of these streams even if that issue was clear.

(In fact, if you write a string to the external-process-output-stream
and then FORCE-OUTPUT on it, you'll get an error indicating that the
file descriptor is "bad".  I assume that "bad" means "closed" in this
case.)

I'm not looking at the code at the moment, but I will try to send a
patch as soon as this starts making sense ...


>
> ================================================================
>
> ;;; This works
> (setf foo (ccl:run-program "cat" () :wait nil :input
> (make-string-input-stream "hello") :output t))
>
> ;;; This is weird
> (setf foo (ccl:run-program "cat" () :wait nil :input :stream :output :stream))
>
> ;;; results in an error
> (write-string "hello" (ccl:external-process-input-stream foo))
> #|
> >  Error: No applicable method for args:
> >          (#<FD-CHARACTER-INPUT-STREAM (NIL/4) #x566423E> "hello" 0 5)
> >          to #<STANDARD-GENERIC-FUNCTION CCL:STREAM-WRITE-STRING #x50967F6>
> >  While executing: #<CCL::STANDARD-KERNEL-METHOD NO-APPLICABLE-METHOD (T)>
> |#
>
> ;;; no error but doesn't make sense, writes output to openmcl listener?
> (write-string "hello" (ccl:external-process-output-stream foo))
>
> ;;; as expected
> (streamp (ccl:external-process-input-stream foo)) ;; => T
>
> ;;; shouldn't the input stream be an output stream it is output from
> openmcl to the external process?
> (input-stream-p (ccl:external-process-input-stream foo)) ;; => T
> (input-stream-p (ccl:external-process-output-stream foo)) ;; => NIL
> (output-stream-p (ccl:external-process-input-stream foo)) ;; => NIL
> (output-stream-p (ccl:external-process-output-stream foo)) ;; => T
>
> ;;; we can't read the external process output
> (read-line (ccl:external-process-output-stream foo))
> #|
> >  Error: No applicable method for args:
> >          (#<FD-CHARACTER-OUTPUT-STREAM (NIL/13) #x5664386>)
> >          to #<STANDARD-GENERIC-FUNCTION CCL:STREAM-READ-LINE #x5095E8E>
> >  While executing: #<CCL::STANDARD-KERNEL-METHOD NO-APPLICABLE-METHOD (T)>
> |#
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel
>
>

_______________________________________________
Openmcl-devel mailing list
Openmcl-devel at clozure.com
http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel



More information about the Openmcl-devel mailing list