Date: Sun, 12 Apr 2026 09:50:11 -0700 From: Gleb Smirnoff <glebius@freebsd.org> To: Olivier Cochard <olivier@freebsd.org>, des@freebsd.org Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: c5961b6fcfe0 - main - yes: fix argv test race between fork and exec Message-ID: <advNQ8tG3ijzM8ls@cell.glebi.us> In-Reply-To: <69d3ebe6.1f204.7943777e@gitrepo.freebsd.org>
index | next in thread | previous in thread | raw e-mail
On Mon, Apr 06, 2026 at 05:22:46PM +0000, Olivier Cochard wrote: O> The branch main has been updated by olivier: O> O> URL: https://cgit.FreeBSD.org/src/commit/?id=c5961b6fcfe0f3587be11187a9c666a7fa200f4b O> O> commit c5961b6fcfe0f3587be11187a9c666a7fa200f4b O> Author: Olivier Cochard <olivier@FreeBSD.org> O> AuthorDate: 2026-04-06 17:17:49 +0000 O> Commit: Olivier Cochard <olivier@FreeBSD.org> O> CommitDate: 2026-04-06 17:22:25 +0000 O> O> yes: fix argv test race between fork and exec O> O> The argv test checks ps(1) output immediately after backgrounding yes(1), but O> the forked child briefly shows the parent shell's argv before exec(2) replaces it. O> This caused intermittent failures where ps(1) captured the atf shell wrapper O> command line instead of "yes y". O> O> Approved by: des O> Sponsored by: Netflix O> Differential Revision: https://reviews.freebsd.org/D56231 O> --- O> usr.bin/yes/tests/yes_test.sh | 2 ++ O> 1 file changed, 2 insertions(+) O> O> diff --git a/usr.bin/yes/tests/yes_test.sh b/usr.bin/yes/tests/yes_test.sh O> index f4c04e186536..797ac5f6ac9f 100644 O> --- a/usr.bin/yes/tests/yes_test.sh O> +++ b/usr.bin/yes/tests/yes_test.sh O> @@ -52,6 +52,8 @@ argv_body() O> { O> yes y >/dev/null & O> local pid=$! O> + # Wait for yes(1) to exec before checking args O> + sleep 0.1 O> atf_check -o inline:"yes y\n" ps -o args= $pid O> kill $pid O> wait This kind of fix doesn't make it 100% flakyless, but adds a 100% guaranteed 0.1 second test execution time overhead. In general, all sh(1) based tests that create a background process should have a wait cycle with `sleep 0.01` in it. In this particular case the problem is that we wait for the condition that is the actual thing that we check. What can be done here is that the wait cycle is not endless, but limited to say 10 seconds, and test shell fail unless we see expected argv within this timeout period. `grep -r sleep\ 0.01 src/tests` can provide some examples of such wait cycles. -- Gleb Smirnoffhome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?advNQ8tG3ijzM8ls>
