On Sunday 19 June 2011 21:02:57 you wrote:
> > 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.
> less tries to do some tricks with the TTY; try :pty T.
Philipp, thanks for your answer. I have tried :pty with the three possible values,
nil, t, and a stream opened just before run-program like this:
(defun test (&aux proc1 mytty 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 mytty (open "/dev/tty" :direction :io :if-exists :append ))
(setq proc1 (run-program "/bin/less" nil :input :stream :output t :wait nil :pty mytty))
(setq stream1 (process-input proc1)) (write-line "Hello, World!" stream1)
(write-char #\Newline stream1) (finish-output stream1) (close stream1) (process-wait proc1)
in the two cases where :pty is not nil, the result is that the /bin/less process does not hang
anymore, but stops immediately with a return like:
#<sb-impl::process :exited 0>
So there is well something with :pty ... but if /bin/less does something tricky, it is very tricky.
Is it possible that this problem is the same as an old sbcl problem linked to setpgrp in the run-
program.c source, and mentioned along the years in many forums? Finally I have never found a
definitive answer in any documentation about this.
in the function spawn in run-program.c:
/* Put us in our own process group. */
#elif defined(SVR4) || defined(__linux__) || defined(__osf__)
Anyway, thanks for any clue, hint, pointer, idea...