Dear StackExchange members,
I recently began toying around with Common Lisp and want to create a web interface for administrating a modded Minecraft server. I already tried out this solution but in this case the function just hangs and never returns.
My code looks like this:
(defvar *proc*)
(defun create-minecraft-proc ()
(let* ((binary "/usr/bin/java")
(jar "/home/user/temp/Vanilla 1.8/minecraft.jar")
(dir "/home/user/temp/Vanilla 1.8")
(args (list "-jar" jar "nogui")))
(setf *proc* (sb-ext:run-program binary args :directory dir :wait nil :input :stream :output :stream))))
(defun copy-stream (in out)
(loop for line = (read-line in nil nil)
while line
do (write-line line out)))
(defun get-minecraft-output ()
(with-open-stream (proc-stream (process-output *proc*))
(with-output-to-string (out)
(copy-stream (process-output *proc*) out)))
How can I get a string containing the complete process output till that time without having to wait for it to terminate?