[plt-scheme] the make-pipe
(module test-mem mzscheme
(require (lib "process.ss"))
(define null-port (open-output-file "/dev/null" 'append))
(define null-iport (open-input-file "/dev/null"))
(define std-oport (current-output-port))
(define (x) (let-values ([(r w) (make-pipe)])
(process/ports w null-iport null-port "/sbin/sysctl -a")
(process/ports std-oport r null-port "grep
vm.min_free_kbytes")
))
(define (y) (process/ports std-oport null-iport null-port "/sbin/sysctl
-a| grep vm.min_free.kbytes"))
(define (z)
(let-values ([(r w) (make-pipe)])
(process/ports w null-iport null-port "/sbin/sysctl -a")
(let loop ()
(let ([v (read-line r)])
(if (eof-object? r)
(void)
(begin
(fprintf std-oport "~a~n" v)
(loop))
)))))
)
------------------------------------
Welcome to DrScheme, version 371.3-svn7nov2007 [3m].
Language: (module ...).
> (x)
(#f #f 11744 #f #<procedure:control>)
> (y)
(#f #f 11745 #f #<procedure:control>)
vm.min_free_kbytes = 5858
1.why (x) and (y) is different?
2. why (z) could not terminate?
Thanks
--
Gang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20071206/c5acbba0/attachment.html>