[plt-scheme] DrScheme becomes unstable after using (system ...) function, any suggestions?
While trying to use the system function from process.ss library, I
discovered that DrScheme becomes unstable after calling this procedure
several hundred times. Here is the bug report that I submitted (#9119):
http://bugs.plt-scheme.org/query/?cmd=view%20audit-trail&database=default&pr=9119&return_url=http%3A%2F%2Fbugs.plt-scheme.org%2Fquery%2F%3Fdatabase%3Ddefault%3Bdebug%3D%3Bcmd%3Dsubmit%20query%3BState%3Dany%3Bignoreclosed%3DIgnore%20Closed%3BSynopsis%3Ddrscheme%3Bmultitext%3D%3Bcolumns%3DState%3Bcolumns%3DSynopsis%3Bcolumns%3DCategory%3Bcolumns%3DLast-Modified%3Bcolumns%3DRelease%3Bsortby%3DNumber
In short, my program makes about 100 calls per run similar to:
(system "a-program.exe > test.txt")
and compares the test.txt to an expected output.
and after hitting "Run" button about 3 times, DrScheme terminates
without any warning or error message. I am running 371.3 on Windows XP.
The exe that is run via system doesn't seem to matter, neither does
using Scheme/Limit Memory... option. MzScheme has no problem with the
program when run outside DrScheme.
I need expert opinion on what I can do to solve this problem, short of
ditching DrScheme. As a newbie Scheme user, I would very much like to
use DrScheme to develop instead of wrestling with Emacs or plain editors.
If you are curious about the program, I just began implementing a Scheme
compiler and test suite following Abdulaziz Ghuloum's paper "An
Incremental Approach to Compiler Construction" to teach myself Scheme.
For each of the hundreds of tests, it compiles a small test program,
runs it and compares its output to expected output.
Thanks for any help in advance,
Yavuz
For the record here are the things I have already tried:
I tried to use shell-execute:
(shell-execute "" "cmd.exe" "/C .\\a-program.exe > test.txt"
(current-directory) 'sw_showminnoactive))
but it doesn't seem to work (probably because shell-execute is
asynchronous and the file is not always updated when the comparison is
done).
I also tried to write a 'clean' version of the system function:
(define (system/clean cmd)
(if (string? cmd)
(let ((p (process cmd)))
((car (cddddr p)) 'wait)
(display ((car (cddddr p)) 'status)) ; just for debugging
(close-input-port (car p))
(close-output-port (cadr p))
(close-input-port (cadddr p))
(error 'system/clean "not a string ---" cmd))))
and to call it with
(system/clean "a-program.exe > test.txt")
but it still doesn't seem to finish writing the file by the time the
comparison is done. I added 1-2sec waits, still no go. (Interestingly,
the file seems to be written eventually after the program finishes
because a consecutive run passes the first such comparison.)