fix wait loop in read proc