The current code caches pending events in lp->status in some situations. This is useful so linux_nat_wait notices an event we have already waited for, it is handled immediatelly without waitpid'ing. It works nicelly in non-async mode, because target_wait is always called after proceeding the target. This pending event caching bypasses the event loop, so we can have the case where an event in one thread goes unnoticed until some other event happens. There's code currently that tried to detected this in linux_nat_resume, and puts an special wake event token in the event pipe. This logic is racy and can brake in several corner case situations, especially with non-stop mode. Since in async mode we already have a place to cache events, so we don't really need another. With this patch, in async mode, no event is left pending in lp->status. Tested in sync mode, and async mode all-stop, non-stop in x86_64-unknown-linux-gnu. OK? -- Pedro Alves