[gambit-list] open-process on Windows

Marc Feeley feeley at iro.umontreal.ca
Tue Feb 13 14:28:08 EST 2007

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.


Version: GnuPG v1.4.3 (Darwin)


More information about the Gambit-list mailing list