[Openmcl-devel] problem using ccl::run-program

R.Stoye stoye at stoye.com
Sun Oct 19 06:40:36 PDT 2008


run-program fails to capture the output depending on the given  
arguments to :output and :error
It works for pathnames or :stream, it fails for streams (file-stream  
or string-output-stream).
Looking at the code of run-program and get-descriptor-for doesn't  
reveal any obvious bug to me and i see that streams should be handled.
To simplify testing, i used the appended c-code for "simpleout".

;; OK:
(ccl:run-program "/usr/local/bin/simpleout" '() :output "/tmp/ 
simpleout_output.txt" :error "/tmp/simpleout_error.txt")
(ccl:run-program "/usr/local/bin/simpleout"  
'() :output :stream :error :stream) ...


;; Missing Output (err is ok):
(with-open-file (out "/tmp/testout.txt" :direction :output :if- 
exists :supersede :if-does-not-exist :create :sharing :lock)
   (with-open-file (err "/tmp/testerr.txt" :direction :output :if- 
exists :supersede :if-does-not-exist :create :sharing :lock)
     (ccl::run-program "/home/rs/ctests/simpleout" (list) :output  
out :error err)))

;; Missing Output: (err is ok)
(let (the-output the-error)
   (with-output-to-string (out)
     (with-output-to-string (err)
       (ccl::run-program "/Users/Shared/WORK/xcodes/Release/ 
simpleout" (list) :output out :error err)
       (setf the-output (get-output-stream-string out)
	    the-error (get-output-stream-string err))))
   (list the-output the-error))

--------------------------------------------------- c code  
-----------------------------------------------------
/*  simpleout - write something to stdout and stderr */
#include <stdio.h>

int main (int argc, const char * argv[]) {
     printf("Output Hello, World!\n");
     fprintf(stderr, "Error Hello, World\n");
     return 0;
}
--------------------------------------------------- c code  
-----------------------------------------------------

ccl versions tested:
    "Version 1.2-r9739MS-RC1  (DarwinX8664)",
    "Version 1.2-r9733MS-RC1  (LinuxX8664)" and
    "Version 1.2-r10988M-trunk  (DarwinX8664)"


Greetings
Ralf Stoye





More information about the Openmcl-devel mailing list