From: Alexey Dobriyan <adobriyan@gmail.com>
To: Drif Abdelmalek Mohamed Said <drifabdelmalekmohamedsaid@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Shuah Khan <shuah@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/proc: proc-empty-vm: wait for child's SIGSEGV instead of sleep(1)
Date: Sun, 1 Nov 2026 15:57:32 +0300 [thread overview]
Message-ID: <65faff9e-5c1b-42d1-a450-b9c66b08ba25@p183> (raw)
In-Reply-To: <20261023183434.9109-1-drifabdelmalekmohamedsaid@gmail.com>
On Fri, Oct 23, 2026 at 07:34:33PM +0100, Drif Abdelmalek Mohamed Said 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.
OK I recall what's going on here.
The only thing to worry is child pid reuse but child is under ptrace
so it should be fine.
Reviewed-by: Alexey Dobriyan <adobriyan@gmail.com>
> + for (;;) {
> + p = waitpid(pid, &wstatus, 0);
> + if (p == -1 && errno == EINTR)
> + continue;
> + break;
> + }
do/while EINTR loops are shorter:
do {
rv = f();
} while (rv == -1 && errno == EINTR);
next prev parent reply other threads:[~2026-11-01 12:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 18:34 Drif Abdelmalek Mohamed Said
2026-11-01 12:57 ` Alexey Dobriyan [this message]
2026-11-02 4:31 ` Andrew Morton
2026-11-02 19:14 ` DRIF ABDELMALEK MOHAMED SAID
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=65faff9e-5c1b-42d1-a450-b9c66b08ba25@p183 \
--to=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=drifabdelmalekmohamedsaid@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®