Oleg Belozeorov writes:
> Hello!
>
> I'm trying to use an external program interactively (that is, make it
> run along with my Lisp application, get requests and send replies
> etc.) this way:
>
> (let ((process (sb-ext:run-program "/path/to/program" args
> :input :stream
> :output :stream
> :wait nil)))
> (write-line some-string (process-input process))
> ...
> (read-line (process-output process)))
Output to Lisp streams is fully buffered by default in SBCL. Most Unix
programs buffer output to non-terminal output devices, too. Do you ever
flush output to the coprocess? Are you convinced that the coprocess
also flushes output? This is a commonish kind of deadlock with
coprosses; try googling with terms like "coprocess", "buffering", and
"deadlock".
You can make SBCL force the output to the coprocess by adding some
FORCE-OUTPUT calls (perhaps after each READ-LINE). Using a pty instead
of a pair of pipes should cause the coprocess to use line buffering for
its output (though unfortunately SBCL doesn't currently fix the pty's
line termination or have any support for CR/LF as an end-of-line marker,
so you'll have to trim CRs off manually if you use a pty).
Regards,
Richard
|