removed duplicated (and dangerous) call to close(2)