Re: [PATCH] selftests/proc: proc-empty-vm: wait for child's SIGSEGV instead of sleep(1)

From: Andrew Morton

Date: Sun Nov 01 2026 - 23:31:25 EST


On Fri, 23 Oct 2026 19:34:33 +0100 Drif Abdelmalek Mohamed Said <drifabdelmalekmohamedsaid@xxxxxxxxx> wrote:

> The test had a TODO asking for a reliable way to know when the child's
> munmap() has finished, and used sleep(1) in the meantime.
>
> Unmapping the whole address space leaves the child with no code to run,
> so it segfaults. Since it is traced, the SIGSEGV stop is reported to
> the parent through waitpid(), which is exactly the signal the TODO
> wanted. Wait for it there and drop the sleep and the TODO.
>
> The stop is now consumed up front, so SIGKILL the child before the
> final reap.

Thanks, checks out.

My review toy claims

: Separately, tools/testing/selftests/ptrace/vmaccess.c has similar
: sleep-based synchronization. A delayed child can make its attach test
: fail spuriously, or let its vmaccess test run before the intended
: blocked-exec state. That deserves a separate fix.