Richard M Kreuter <kreuter@...> writes:
> 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?
Yes, I did FINISH-OUTPUT after each WRITE-LINE and fflush(stdout) at C
side. Sorry for not mentioning it in previous message.
WBR, Oleg.

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

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)))
But I can't read anything from (process-output process) until the
process is running, and get (the whole) output only when it
terminates. Making FD-STREAMs of Unix pipes and passing them as input
and output parameters to RUN-PROGRAM leads to the same behavior.
Could you tell what am I doing wrong?
Thanks in advance,
-- Oleg.

Community

Help

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

CountryState

JavaScript is required for this form.

I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details