[Larceny-users] directory-files

Jed Davis jdev at panix.com
Thu Feb 8 14:32:03 EST 2007


On Thu, Feb 08, 2007 at 11:15:03AM +0100, Sven.Hartrumpf at FernUni-Hagen.de wrote:
> 
> Thanks for the information Using the svn version, it Works now.
> Please note that my code for open-input-pipe (above)
> is problematic because it won't close processes cleanly.
> The following avoids this problem:
> 
> (define call-with-input-pipe (lambda (command pred)
>   (let* ((results (process command))
>          (input-port (car results))
>          (result (pred input-port)))
>     (unix/wait) ; important in order to remove process
>     result)))

I suggest (unix/waitpid (caddr results)), as otherwise it might pick up
a different dead process that something else had created and was going
to waitpid for.

This still differs from the usual behavior of such things in other
languages, in that it redirects the command's input to an inaccessible
pipe rather than leaving it unchanged from the parent.  A function more
capable than process would help there....

-- 
(let ((C call-with-current-continuation)) (apply (lambda (x y) (x y)) (map
((lambda (r) ((C C) (lambda (s) (r (lambda l (apply (s s) l))))))  (lambda
(f) (lambda (l) (if (null? l) C (lambda (k) (display (car l)) ((f (cdr l))
(C k)))))))    '((#\J #\d #\D #\v #\s) (#\e #\space #\a #\i #\newline)))))



More information about the Larceny-users mailing list