guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

documentation.scm close files


From: Kevin Ryde
Subject: documentation.scm close files
Date: Thu, 08 May 2003 08:58:00 +1000
User-agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux)

In documentation.scm I noticed file-commentary and
find-documentation-in-file don't close their files before returning.
I think it'd be good to do so explicitly,

        * documentation.scm (file-commentary, find-documentation-in-file): Use
        call-with-input-file, so as to close ports when done.

(Patch below, un-indented to make the changes clear.)

I know ports get closed when gc'ed, but I'd suggest it does the system
and the program no good to keep stuff open long after finished with.

As it stands, in fact, by artificially lowering the number of files
available an error can be induced (on my i386 debian at least),

        ulimit -n 30
        guile -s foo.scm

with foo.scm containing

        (use-modules (ice-9 documentation))
        (while #t (file-commentary "/dev/null"))
or
        (use-modules (ice-9 documentation))
        (while #t (search-documentation-files 'car "/dev/null"))

both giving

        ERROR: In procedure open-file:
        ERROR: Too many open files: "/dev/null"

Attachment: documentation.scm.with-input.diff
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]