check for pid being -1 to determine the end of rid,key pairs.