Updated utmp entry search algorithm to follow GNU/Linux description:
https://man7.org/linux/man-pages/man5/utmp.5.html#DESCRIPTION
An entry is found by looking for matching PID. If several such entries
found (for example, due to cleanup failure of old entries) then first
entry with both matching PID and matching 'ut_line' (current terminal)
is used. If not entry has matching 'ut_line' then first entry with
matching PID is used (if getty/init process does not set 'ut_line').
When no single entry is matched by PID, then but at least one entry is
matched current terminal the the first such entry is selected (if getty
does not set correct PID).
This commit uses non-portable Elvis operator is it is already used
everywhere in the code.