test(process): publish timeout stop signal atomically in ExecFileOutput test (#13151)

The child recorded the received signal with writeFileSync, which creates
an empty file before writing. The test polls for existence and reads the
content while the child is still alive, so it could observe '' instead of
SIGINT (main CI run 44898480483). Write to a sibling file and rename it.

Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com>
Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-11-21 17:55:13 +01:00
1 parent f609aa3393
commit df1bd11895
1 file changed
+4 -1
+4 -1
View File
@@ -352,10 +352,13 @@ describe.skipIf(process.platform === "win32")(
const ready = join(directory, "ready");
const stopped = join(directory, "stopped");
const release = join(directory, "release");
// Publish the signal by rename so the poller never reads a created but
// still-empty file while the child is alive.
const script = [
'const fs = require("node:fs");',
'for (const name of ["SIGINT", "SIGTERM"]) process.on(name, () => {',
` fs.writeFileSync(${JSON.stringify(stopped)}, name);`,
` fs.writeFileSync(${JSON.stringify(`${stopped}.partial`)}, name);`,
` fs.renameSync(${JSON.stringify(`${stopped}.partial`)}, ${JSON.stringify(stopped)});`,
` const exitCode = ${JSON.stringify(exitCode)};`,
" if (exitCode !== null) process.exit(exitCode);",
"});",