Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Understanding SB-EXT:RUN-PROCESS

60 views
Skip to first unread message

Josef Wolf

unread,
Mar 23, 2012, 6:14:53 AM3/23/12
to
Hello,

I am trying to send some output to the printer. So I tried this:

(let ((proc (sb-ext:run-program "a2ps" '()
:search t
:input :stream
:output nil)))
(format (sb-ext:process-input proc) "huhu~%")
(sb-ext:process-close proc))

But somehow, SB-EXT:PROCESS-CLOSE seems to be ignored, and a2ps hangs
indefinitely, trying to read more input from its stdin. Does anybody have any
idea what I might be missing here?

Nicolas Neuss

unread,
Mar 23, 2012, 9:54:16 AM3/23/12
to
This works for me:

(let* ((process (sb-ext:run-program
"/bin/cat" '()
:wait nil :input :stream :output :stream))
(input (sb-ext:process-input process))
(output (sb-ext:process-output process)))
(write-line "Hello" input)
(force-output input)
(print (read-line output))
(close input)
(close output))

(Maybe the missing FORCE-OUTPUT or the missing :wait nil is your problem?)

Nicolas

Josef Wolf

unread,
Mar 26, 2012, 10:55:41 AM3/26/12
to
On 2012-03-23, Nicolas Neuss <last...@scipolis.de> wrote:
> (let* ((process (sb-ext:run-program
> "/bin/cat" '()
> :wait nil :input :stream :output :stream))
> (input (sb-ext:process-input process))
> (output (sb-ext:process-output process)))
> (write-line "Hello" input)
> (force-output input)
> (print (read-line output))
> (close input)
> (close output))

Thanks for the hint, Nicolas. That helped me to get closer to the
problem. Please see below.

> (Maybe the missing FORCE-OUTPUT or the missing :wait nil is your problem?)

No, the missing FORCE-OUTPUT don't seem to be the problem. In addition,
PROCESS-CLOSE shold call FORCE-OUTPUT before closing, IMHO.

The real problem seems to be a little bit more subtle. First thing is, I need
to add

:wait nil

to the lambda-list. (well reading the docs helps. Sorry, my fault )

Now comes the subtle thing: Once RUN-PROGRAM is called without
the :WAIT NIL parameter, further calls to RUN-PROGRAM will no longer close the
streams properly, regardless whether :WAIT NIL parameter is included in those
later calls or not. The same holds true if I ever call SB-EXT:PROCESS-WAIT to
collect zombies. I need to quit the sbcl instance and start another one to get
it working again.

Might this be a bug in sbcl-1.0.55? Or is it related to SLIME?
0 new messages