Be sure to close directory file descriptor if fdopendir() fails.