[gambit-list] copy-file on windows & links

Christoph Bauer christoph.bauer at lmsintl.com
Thu Feb 26 08:25:43 EST 2009


> Christoph Bauer wrote:
> > But I have another question. Normally on an xterm Ctrl-S stops the 
> > output from a program, but it doesn't work with my gambit 
> script. So 
> > do I have to catch/enable a signal?
> 
> I'm not 100% sure here, but I believe that if you use 
> display, write, or pretty-print, using ctl-s will probably 
> stop your output because these procedures write to the 
> standart output port. On the other hand, the pp procedure 
> writes directly to the terminal, and thus this output cannot 
> be re-directed. So if Ctl-s redirects the stdin/stdout, it is 
> understandable that output from pp is still there.
> 
> Did you only used pp to output from your script?
> 
No, I use display. In fact I defined my own output
function writeln as:

(define (string-rep obj)
  (if (string? obj) obj
      (object->string obj)))

(define (writeln #!rest args)
  (display (apply string-append (map string-rep args)))
  (newline))

Most of the output comes from subprocesses. I read the
output and use writeln to show it:

(define (run-process-args cmd args #!key (exception-on-status #t) )
  (writeln (string-join (cons cmd args)))
  (let ((port
         (open-process (list path: cmd arguments: args))))
    (letrec ((loop (lambda (acc)
                     (let ((line (read-line port)))
                       (if (eof-object? line)
                           (let ((status (process-status port)))
                             (close-port port)
                             (if (or (not exception-on-status) (= status
0)) acc
                                 (raise (list cmd args '=> status))))
                           (begin
                             (writeln line)
                             (loop (cons line acc))))))))
      (reverse (loop '())))))

So I guess most of the time is spent in (read-line).

Christoph



More information about the Gambit-list mailing list