Merge "Add extra checks around the profile file descriptor." into pi-dev