With SBCL 1.0.40 on a Debian Squeeze AMD64, the following function gives a problem:
(defun test (&aux proc1 stream1)
"this function should run the program /bin/less and pipe into its stdin the string
hello, world ; then /bin/less should display the text and wait for terminal input 'q' to
quit then the function should close everything and return properly .....
but this does not work... why?"
(setq proc1 (run-program "/bin/less" nil :input :stream :output t :wait nil))
(setq stream1 (process-input proc1)) (write-line "Hello, World!" stream1)
(write-char #\Newline stream1) (finish-output stream1) (close stream1)
(process-wait proc1) (process-close proc1))
I have seen with ps -ef that the process /bin/less has been started as child of the sbcl
process, and with lsof -p I could see that sbcl has opened a pipe to the stdin of
/bin/less, and that /bin/less has its stdin connected to the same pipe (same inode in
lsof), ... but .... nothing else happened.
The two processes hang, nothing is displayed. I expected to have
/bin/less display the string "Hello, World!" then wait for a 'q' to quit, and return to
the sbcl prompt. cat, /bin/bash instead of /bin/less work correctly as expected.
Can anybody give a hint to a solution, is it a mistake of me?
Thanks a lot in advance and best regards to all.