1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// ABOUTME: Shared helper for the tests that exec a shell stand-in they just wrote: retries a
// ABOUTME: runner call whose spawn failed with ETXTBSY, the race a concurrent test's fork opens
//
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2026 dravr.ai
//! A test that writes an executable script and then execs it races every
//! other test in the same binary. While one test holds the script's write
//! descriptor open, another test's runner may fork; the child inherits that
//! descriptor and keeps it until its own exec closes it (close-on-exec). An
//! exec of the script in that window fails with `ETXTBSY` ("Text file busy",
//! os error 26) on Linux. Production never execs a file it has just written,
//! so the race exists only here, and only the spawn of such a call is retried:
//! every other error, including every other spawn failure, is returned as is.
use Future;
use Duration;
use ;
use sleep;
/// How many times a call is made before its `ETXTBSY` is returned.
const ATTEMPTS: u32 = 10;
/// Pause between attempts: long enough for a sibling's fork to reach exec.
const PAUSE: Duration = from_millis;
/// True for exactly the runner error a spawn that hit `ETXTBSY` produces:
/// runners report a spawn failure as an internal `Failed to spawn …: {io error}`,
/// and the io error displays its errno last.
/// Run `call`, retrying it while its spawn fails with `ETXTBSY`, up to
/// [`ATTEMPTS`] times; any other outcome is returned on the first attempt.
pub async