For the common case where we have pts/ or tty do it straight away. Otherwise traverse /dev for a match. This fixes ps(1) when it is executed over a serial terminal with tty names like ttyAMA0.