if use ps_pid.poll() to check for termination condition, there is a
race condition. consider this, the check for ps_pid.poll() succeed
and continue to process the output. when the output is being
processed, the "ps_pid" process terminated, generating some more
output, which hasn't yet been read by pidcat process. after pidcat
continues next loop iteration, the ps_pid.poll() check terminate the
loop, and the remaining output is lost. if the target process's pid
is in the lost output, then the target pid can't be retrieved.