Page MenuHomeFreeBSD

yes: fix argv test race between fork and exec
AcceptedPublic

Authored by olivier on Thu, Apr 2, 11:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 4, 4:14 PM
Unknown Object (File)
Sat, Apr 4, 4:12 PM
Unknown Object (File)
Fri, Apr 3, 4:55 PM
Subscribers
None

Details

Reviewers
des
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

Lint
Lint Skipped
Unit
Tests Skipped

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