[Larceny-users] directory-files

Sven.Hartrumpf at FernUni-Hagen.de Sven.Hartrumpf at FernUni-Hagen.de
Thu Feb 22 10:26:04 EST 2007


Thu, 8 Feb 2007 14:32:03 -0500, jdev wrote:

> On Thu, Feb 08, 2007 at 11:15:03AM +0100, Sven Hartrumpf 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.

Oh, yes. Thanks for the suggestion!  I found out that closing the ports is
important: if I don't close any ports, the program crashes around the 512th
call of call-with-input-pipe; if I close only the input-port, it crashes
around the 1024th call of call-with-input-pipe. This is probably caused by
the following ulimit:

open files                      (-n) 1024

So, now I am using the following definition (I hope this one will live a
little longer):

(define call-with-input-pipe (lambda (command pred)
  (let* ((results (process (if (string? command)
                             command
                             (reduce-r (lambda (arg result)
                                         (string-append arg " " result))
                                       command))))
         (result (pred (car results))))
    (close-input-port (car results))
    (close-output-port (cadr results))
    (unix/waitpid (caddr results))
    result)))


Ciao
Sven
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://lists.ccs.neu.edu/pipermail/larceny-users/attachments/20070222/25d719e5/attachment.bin 


More information about the Larceny-users mailing list