Move logic for listing open file descriptors to a separate helper library.