modify close_fds logic