Fix build without HAVE_MMAP
Don't close fd when failure occurs, it is const
Fix test due to test.tcl being leftover on failures
Don't close sockets passed in (fdclose(3) would be nice...)