[plt-scheme] Trouble killing sub-processes

From: Jepri (jepri at babylon.alphacomplex.org)
Date: Sun Jun 5 02:31:43 EDT 2005

Hi all,
  I've been writing a program in Scheme to wrap the command line program 
rsync and do automated uploads.  The program is working fine, and I'm 
reading rsync's output to display in a progress meter.  But if I try to 
kill rsync, rsync doesn't stop.  If I try to close the ports before or 
after the kill the whole program hangs until I kill rsync from the task 
manager, at which point my program continues.

I've been pounding on this all day - and I've googled, looked for a 
debugger and tried increasingly odd strategies to get this to work.  Is 
there anyone on the list with experience in this, or has a reference to 
some code I could look at to see the right way to do it?  I am a 
beginner in this, so it's likely I've done something newbish, but I just 
can't see it.

I've got a test case showing the code I'm using.  If I don't read from 
the port in (display (read-char (first ports))), rsync will exit when 
killed.

(require (lib "process"))
(require (lib "13.ss" "srfi"))
(define rsync-path "c:/Program Files/cwrsync/rsync.exe")
(define machine-id "hostname")(define account-name "testuser")
(putenv "RSYNC_PASSWORD" "elided")
(define command (lambda () (string-concatenate (list "\"" rsync-path "\" 
--recursive --partial-dir=/hostname/partial_downloads  --delete-after 
--temp-dir=/" machine-id "/  --checksum --progress --stats --compress 
--timeout=600 '/Documents and Settings' rsync://" account-name 
"@servername/" account-name "/" machine-id "/files/"))))
(define ports (process (command)))
(display (read-char (first ports)))  <--this line appears to stop kill 
from working

((fifth ports) 'kill)
(display ((fifth ports) 'status))
;;(close-input-port (first ports))  <-- this seems to block, whether 
before or after the kill
(exit)



Posted on the users mailing list.