Page MenuHomeFreeBSD

yes: fix argv test race between fork and exec
ClosedPublic

Authored by olivier on Thu, Apr 2, 11:26 PM.
Tags
None
Referenced Files
F154122830: D56231.id.diff
Sun, Apr 26, 8:39 AM
Unknown Object (File)
Sat, Apr 25, 12:00 AM
Unknown Object (File)
Sun, Apr 19, 9:23 AM
Unknown Object (File)
Sun, Apr 19, 5:12 AM
Unknown Object (File)
Sun, Apr 19, 4:53 AM
Unknown Object (File)
Sat, Apr 18, 11:54 AM
Unknown Object (File)
Sat, Apr 18, 11:40 AM
Unknown Object (File)
Sat, Apr 18, 11:39 AM
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.Sat, Apr 4, 8:46 AM