Fix potential 'race' where the first timeout would be hit
Fix potential 'race' where the first timeout would be hit

Process A writes to the queue
Process B executes + clears the queue
Process C writes to the queue
Process A will now never be head and will just sit until the queue
is empty again or the timeout is hit.

Also fix definite race where the queue could get broken because part
of the code was expecting PIDs

djs55/planex,simonjbeaumont/planex,djs55/planex,djs55/planex,simonjbeaumont/planex,simonjbeaumont/planex