-[ Tue, Dec 13, 2011 at 01:42:35PM +0100, Andy Wingo ]---- > If you close the fd, isn't the memory unmapped? Isn't that a bad thing? > > Maybe I was just under a big misconception here :)
That's a common misconception. The mapping of VM space to disk storage is unrelated to the file descriptor set (or any program would have at least a file descriptor opened for itself, since any program is mapped into memory). Compare for instance cat /proc/1/maps with ls -l /proc/1/fd. As I said, the attached patch, which do closes the fd, actually works (ie make check and my personal program works). So the memory is clearly not unmapped :-)