Fix check for max_fd == -1 should actually be max_fd != -1