I'm a little worried by the amount of file descriptors left opened
after the objcode is mmaped.
I saw this "note to self" from objcodes.c:
/* FIXME: we leak ourselves and the file descriptor. but then again so does
dlopen(). */
So apparently the author was well aware of the problem but decided to
ignore it, despite the fd being used nowhere as far as I can see
(also, I don't understand the remark about dlopen leaking a fd).
Anyway, the attached patch (which closes the fd and stores -1 inplace
of it in the cell) seams to works and seams to fix the issue (ie. no more
pending opened fd for .go files)
diff --git a/libguile/objcodes.c b/libguile/objcodes.c
index 536094f..9fa8b00 100644
--- a/libguile/objcodes.c
+++ b/libguile/objcodes.c
@@ -203,12 +203,11 @@ make_objcode_from_file (int fd)
scm_from_size_t (total_len)));
}
- /* FIXME: we leak ourselves and the file descriptor. but then again so does
- dlopen(). */
+ (void) close (fd);
return scm_permanent_object
(scm_double_cell (SCM_MAKE_OBJCODE_TAG (SCM_OBJCODE_TYPE_MMAP, 0),
(scm_t_bits)(addr + strlen (SCM_OBJCODE_COOKIE)),
- SCM_UNPACK (scm_from_int (fd)), 0));
+ SCM_UNPACK (scm_from_int (-1)), 0));
}
#else
{