do_wait: fix the theoretical race with stop/trace/cont