From: Chris Hanson Date: Wed, 22 Oct 1997 05:18:12 +0000 (+0000) Subject: Changes to support subprocesses under NT. Requires microcode version X-Git-Tag: 20090517-FFI~4985 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=c98d869e4b4c69f886d5e3422c45d7922a24343f;p=mit-scheme.git Changes to support subprocesses under NT. Requires microcode version 11.159 or later. --- diff --git a/v7/src/runtime/ntprm.scm b/v7/src/runtime/ntprm.scm index 9153dd65e..90b92baa1 100644 --- a/v7/src/runtime/ntprm.scm +++ b/v7/src/runtime/ntprm.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: ntprm.scm,v 1.11 1997/01/05 23:43:59 cph Exp $ +$Id: ntprm.scm,v 1.12 1997/10/22 05:18:00 cph Exp $ Copyright (c) 1992-97 Massachusetts Institute of Technology @@ -311,7 +311,11 @@ MIT in each case. |# (reset-environment-variables!) (cache-console-channel-descriptor!)))) (reset!) - (add-event-receiver! event:after-restart reset!))) + (add-event-receiver! event:after-restart reset!)) + (set! nt/hide-subprocess-windows? #t) + (set! nt/subprocess-argument-quote-char #f) + (set! nt/subprocess-argument-escape-char #f) + unspecific) (define (dos/fs-drive-type pathname) ;; (system-name . [nfs-]mount-point) @@ -430,82 +434,180 @@ MIT in each case. |# (set! port #f) unspecific)))))))))) -(define-structure (nt-select-registry - (conc-name nt-select-registry/) - (constructor nt-select-registry/make)) - console +(define-structure (nt-select-registry (conc-name nt-select-registry/)) descriptors) -(define-integrable (find-descriptor df dl) - (list-search-positive dl - (lambda (d) - (= d df)))) - (define (make-select-registry . descriptors) - (cond ((find-descriptor console-channel-descriptor descriptors) - => (lambda (ccd) - (nt-select-registry/make console-channel-descriptor - (delq! ccd descriptors)))) - (else - (nt-select-registry/make false descriptors)))) + (make-nt-select-registry descriptors)) (define (add-to-select-registry! registry descriptor) - (cond ((= descriptor console-channel-descriptor) - (set-nt-select-registry/console! registry console-channel-descriptor)) - ((not (find-descriptor descriptor - (nt-select-registry/descriptors registry))) - (set-nt-select-registry/descriptors! - registry - (cons descriptor (nt-select-registry/descriptors registry)))))) + (if (not (memv descriptor (nt-select-registry/descriptors registry))) + (set-nt-select-registry/descriptors! + registry + (cons descriptor (nt-select-registry/descriptors registry))))) (define (remove-from-select-registry! registry descriptor) - (cond ((= descriptor console-channel-descriptor) - (set-nt-select-registry/console! registry false)) - ((find-descriptor descriptor (nt-select-registry/descriptors registry)) - => (lambda (dr) - (set-nt-select-registry/descriptors! - registry - (delq! dr (nt-select-registry/descriptors registry))))))) + (set-nt-select-registry/descriptors! + registry + (delv! descriptor (nt-select-registry/descriptors registry)))) (define (select-registry-test registry block?) - (let ((handles (list->vector (nt-select-registry/descriptors registry)))) - (let ((nhand (vector-length handles)) - (result - (select-internal (nt-select-registry/console registry) - handles - block?))) - (cond ((fix:< result 0) - (error "Illegal result from select-internal:" result)) - ((fix:= result 0) #f) - ((fix:<= result nhand) - (list (vector-ref handles (fix:- result 1)))) - ((fix:= result (fix:+ nhand 1)) - (list (nt-select-registry/console registry))) - (else 'INTERRUPT))))) + (let ((descriptors (list->vector (nt-select-registry/descriptors registry)))) + (let ((result + ((ucode-primitive nt:waitformultipleobjects 3) + descriptors #f block?))) + (cond ((and (fix:<= 0 result) (fix:< result (vector-length descriptors))) + (list (vector-ref descriptors result))) + ((fix:= result -1) #f) + ((fix:= result -2) 'INTERRUPT) + ((fix:= result -3) 'PROCESS-STATUS-CHANGE) + (else (error "Illegal result from select-internal:" result)))))) (define (select-descriptor descriptor block?) (let ((result - (if (= descriptor console-channel-descriptor) - (select-internal #t '#() block?) - (select-internal #f (vector descriptor) block?)))) + ((ucode-primitive nt:waitformultipleobjects 3) + (vector descriptor) #f block?))) (case result - ((0) #f) - ((1) 'INPUT-AVAILABLE) - ((2 3) 'INTERRUPT) + ((0) 'INPUT-AVAILABLE) + ((-1) #f) + ((-2) 'INTERRUPT) + ((-3) 'PROCESS-STATUS-CHANGE) (else (error "Illegal result from select-internal:" result))))) -(define (select-internal console? handles block?) - (let ((nt/QS_ALLINPUT #xFF) - (nt/INFINITE #xFFFFFFFF)) - (let ((timeout (if block? nt/INFINITE 0))) - (if console? - ((ucode-primitive nt:msgwaitformultipleobjects 4) - handles #f timeout nt/QS_ALLINPUT) - ((ucode-primitive nt:waitformultipleobjects 3) - handles #f timeout))))) - (define console-channel-descriptor) (define (cache-console-channel-descriptor!) - (set! console-channel-descriptor ((ucode-primitive get-handle 1) 1)) - unspecific) \ No newline at end of file + (set! console-channel-descriptor + (channel-descriptor-for-select (tty-input-channel))) + unspecific) + +(define nt/hide-subprocess-windows?) +(define nt/subprocess-argument-quote-char) +(define nt/subprocess-argument-escape-char) + +(define (os/make-subprocess filename arguments environment working-directory + ctty stdin stdout stderr) + (if ctty + (error "Can't manipulate controlling terminal of subprocess:" ctty)) + ((ucode-primitive nt-make-subprocess 8) + filename + (nt/rewrite-subprocess-arguments filename (vector->list arguments)) + (and environment + (nt/rewrite-subprocess-environment (vector->list environment))) + working-directory + stdin + stdout + stderr + (vector nt/hide-subprocess-windows?))) + +(define (nt/rewrite-subprocess-environment strings) + (let ((strings + (map car + (sort (map (lambda (binding) + (cons binding + (or (string-find-next-char binding #\=) + (string-length binding)))) + strings) + (lambda (s1 s2) + (substring