[Openmcl-devel] duplicating a stream

Pascal J. Bourguignon pjb at informatimago.com
Mon Mar 26 11:36:28 PDT 2012


When calling run-program, one need to pass a :shared stream.

Since I may get non shared file streams (by default they're :private),
I'd want to "duplicate" the stream, making a shared stream to give to
run-program, using the same stream-device:

  (defun wrap-stream (direction stream)
    ;; Since stream may not be shared, we make a new stream for
    ;; the process.
    (typecase stream
      (stream     (ccl::make-basic-stream-instance
                   (if (eql :input direction)
                       'file-character-input-stream
                       'file-character-output-stream)
                   :stream-device (ccl::stream-device stream direction)
                   :direction direction
                   :element-type 'character
                   :sharing :lock
                   :encoding ccl:*default-file-character-encoding*
                   :line-termination #+windows :windows #-windows :unix
                   :auto-close t))
      (otherwise  stream)))

Unfortunately that fails with:

    There is no applicable method for the generic function:
      #<standard-generic-function ccl:class-own-wrapper #x302000032F0F>
    when called with arguments:
      (com.informatimago.run-program::file-character-output-stream)
       [Condition of type simple-error]

What did I do wrong?


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.



More information about the Openmcl-devel mailing list