Page MenuHomeFreeBSD

yes: fix argv test race between fork and exec
ClosedPublic

Authored by olivier on Apr 2 2026, 11:26 PM.
Tags
None
Referenced Files
F157751057: D56231.diff
Sun, May 24, 8:24 PM
F157750655: D56231.diff
Sun, May 24, 8:18 PM
Unknown Object (File)
Thu, May 14, 3:36 PM
Unknown Object (File)
Thu, May 14, 11:23 AM
Unknown Object (File)
Thu, May 14, 8:46 AM
Unknown Object (File)
Thu, May 14, 1:45 AM
Unknown Object (File)
Mon, May 11, 5:31 AM
Unknown Object (File)
Thu, May 7, 1:29 PM
Subscribers

Details

Summary

The argv test checks ps(1) output immediately after backgrounding yes(1), but the forked child briefly shows the parent shell's argv before exec(2) replaces it. This caused intermittent failures where ps(1) captured the atf shell wrapper command line instead of "yes y".

Poll until the process has exec'd into yes(1) before asserting its args.

Test Plan

Current flaky behaviour:

Original stderr
---------------

Fail: stdout does not match expected value
--- /tmp/kyua.jxCZUT/5501/work/atf-check.apm5lx	2026-03-31 18:58:49.729331000 +0000
+++ /tmp/kyua.jxCZUT/5501/work/check.3prQPn/stdout	2026-03-31 18:58:49.728847000 +0000
@@ -1 +1 @@
-yes y
+/bin/sh -c Atf_Check='/usr/libexec/atf-check' ; Atf_Shell='/bin/sh' ; . /usr/share/atf/libatf-sh.subr ; . /usr/tests/usr.bin/yes/yes_test ; main "${@}" /usr/tests/usr.bin/yes/yes_test -vallow_sysctl_side_effects=1 -vcam_test_device=/dev/ada6 -vci=true -vdisks=/dev/ada6 /dev/ada7 /dev/ada8 /dev/ada9 /dev/ada10 -vunprivileged-user=tests -vunprivileged_user=tests -r/tmp/kyua.jxCZUT/5501/result.atf argv

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

olivier created this revision.

I should have thought of this... but honestly, just sleep 0.1 should be fine, cf. a9c72543d287afa8dd30bec0f49873e88057c192.

This revision is now accepted and ready to land.Apr 4 2026, 8:46 AM