"Bill Kelly" <billk / cts.com> writes:

> From: "ts" <decoux / moulon.inra.fr>
> >  The file will be closed when it will be garbage collected.

> I don't know if I worry too much, but that does set off my potential-
> danger-alarm meter a bit, depending on conceivable circumstances:
> for instance, if the above were in a loop.  Would it be possible to
> run out of file handles before GC was called?

Nope - the interpreter checks and runs GC if it runs out of file handles:

    file = fopen(fname, mode);
    if (!file) {
	if (errno == EMFILE || errno == ENFILE) {
	    rb_gc();
	    file = fopen(fname, mode);
	}
	if (!file) {
	    rb_sys_fail(fname);
	}
    }


Cheers


Dave