Hey there,
First off, thanks for the awesome scheme implementation, I'm really digging it so far.
Here's my question:
On my Windows XP system, running gambit - 4.0 b20, I'm having trouble with the following code: ********************************************************** (let* ((p (open-process "C:/Program Files/GnuWin32/bin/cat.exe"))) (display "1" p) (close-output-port p) (let ((bc (read-all p))) (pp bc)))
********************************************************** I expect the output to always be: (1) but about 1/3 of the time I get: ()
I can't figure why this code would be inconsistent. The 'cat' implementation is (I think) a direct port of GNU cat. In any case I've had the same problem with other binaries that read from STDIN and write to STDOUT.
I've tried inserting calls to (newline), (force-output), using (write) or (write-char) instead of (display), all to no avail.
Any ideas?
Thanks, Aemon
Afficher les réponses par date
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 22-Jan-07, at 11:02 PM, Aemon Cannon wrote:
On my Windows XP system, running gambit - 4.0 b20, I'm having trouble with the following code:
(let* ((p (open-process "C:/Program Files/GnuWin32/bin/cat.exe"))) (display "1" p) (close-output-port p) (let ((bc (read-all p))) (pp bc)))
I expect the output to always be: (1) but about 1/3 of the time I get: ()
I can't figure why this code would be inconsistent. The 'cat' implementation is (I think) a direct port of GNU cat. In any case I've had the same problem with other binaries that read from STDIN and write to STDOUT.
I've tried inserting calls to (newline), (force-output), using (write) or (write-char) instead of (display), all to no avail.
Any ideas?
I tried your example (using the "cat.exe" in MSYS) and I consistently get (1). I suspect that there is a race condition in the code, and that your machine is either faster or slower than mine causing the problem to occur.
You may be able to fix the problem by inserting a call to process- status after the close-output-port to wait for the process to terminate. You can give a timeout for the wait like so:
(process-status p 1.5 999)
This will wait for up to 1.5 seconds and return 999 when the timeout is reached.
Marc