e943dffb
test: the dead pid comes from a true that both systems have
a73x 2026-09-03 19:25
Commit message
src/testtmp.zig
| Old | New | ||
|---|---|---|---|
| @@ -56,10 +56,15 @@ pub const TmpDir = struct { | |||
| 56 | } | 56 | } |
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| 59 | /// A pid nothing holds: `/bin/true`, spawned and waited for. What the | 59 | /// A pid nothing holds: `true`, spawned and waited for. What the reapers ask |
| 60 | /// reapers ask the OS about, made real rather than guessed from pid_max. | 60 | /// the OS about, made real rather than guessed from pid_max. |
| 61 | /// | ||
| 62 | /// Found on PATH rather than spelled absolutely, because the two systems put | ||
| 63 | /// it in different places: `/bin/true` on Linux, `/usr/bin/true` on macOS. | ||
| 64 | /// The absolute Linux spelling failed to spawn on the Mac, and every reaper | ||
| 65 | /// test that asks for a dead pid failed with it. | ||
| 61 | pub fn deadPid() !std.posix.pid_t { | 66 | pub fn deadPid() !std.posix.pid_t { |
| 62 | var child = std.process.Child.init(&.{"/bin/true"}, std.testing.allocator); | 67 | var child = std.process.Child.init(&.{"true"}, std.testing.allocator); |
| 63 | try child.spawn(); | 68 | try child.spawn(); |
| 64 | // Read before the wait: `wait` sets `id` to undefined once the child | 69 | // Read before the wait: `wait` sets `id` to undefined once the child |
| 65 | // is reaped, and an undefined pid parsed out of a name is no pid. | 70 | // is reaped, and an undefined pid parsed out of a name is no pid. |