From e640fa92aeefddb88992ed68f9eb5f0ac0a74538 Mon Sep 17 00:00:00 2001 From: Ben Firshman Date: Wed, 4 Mar 2026 21:53:12 -0600 Subject: [PATCH] fix: use atomic rename in setup_subprocess_double_fork test to prevent race condition The forked child process writes .outbox directly, which means the predictor can observe the file (via os.path.exists) before the content is fully flushed. Write to .outbox.tmp first, then os.rename() to .outbox so the predictor never reads a partially-written file. --- integration-tests/tests/setup_subprocess_double_fork.txtar | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/integration-tests/tests/setup_subprocess_double_fork.txtar b/integration-tests/tests/setup_subprocess_double_fork.txtar index 1044dff276..a11caed189 100644 --- a/integration-tests/tests/setup_subprocess_double_fork.txtar +++ b/integration-tests/tests/setup_subprocess_double_fork.txtar @@ -117,11 +117,13 @@ def main(): os.unlink(".inbox") - with open(".outbox", "w") as outbox: - print(f"---> CHILD ({pid}) sending response") + print(f"---> CHILD ({pid}) sending response") + with open(".outbox.tmp", "w") as outbox: outbox.write("hello " + s) + os.rename(".outbox.tmp", ".outbox") + if time.time() % 10 == 0: if is_child: print(f"---> CHILD ({pid}) " + ("here " * 20))