Skip to content

Commit 3d4cfe6

Browse files
committed
test: publish process readiness after signal setup
1 parent ea11b87 commit 3d4cfe6

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎test/scripts/openclaw-e2e-instance.test.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,12 @@ describe("scripts/lib/openclaw-e2e-instance.sh", () => {
591591
childPath,
592592
[
593593
"const fs = require('node:fs');",
594-
"fs.writeFileSync(process.argv[2], String(process.pid));",
595-
"fs.writeFileSync(process.argv[3], String(process.ppid));",
596594
"process.on('SIGTERM', () => {});",
597595
"process.on('SIGHUP', () => {});",
598596
"setInterval(() => {}, 1000);",
597+
// PID publication lets the shell signal us; install handlers first.
598+
"fs.writeFileSync(process.argv[2], String(process.pid));",
599+
"fs.writeFileSync(process.argv[3], String(process.ppid));",
599600
"",
600601
].join("\n"),
601602
);
@@ -687,12 +688,13 @@ fi
687688
childPath,
688689
[
689690
"const fs = require('node:fs');",
690-
"fs.writeFileSync(process.argv[2], String(process.pid));",
691691
"process.on('SIGTERM', () => {",
692692
" fs.writeFileSync(process.argv[3], 'terminated');",
693693
" process.exit(0);",
694694
"});",
695695
"setInterval(() => {}, 1000);",
696+
// Both PID files announce readiness for immediate group termination.
697+
"fs.writeFileSync(process.argv[2], String(process.pid));",
696698
"",
697699
].join("\n"),
698700
);
@@ -701,13 +703,13 @@ fi
701703
[
702704
"const fs = require('node:fs');",
703705
"const { spawn } = require('node:child_process');",
704-
"fs.writeFileSync(process.argv[3], String(process.pid));",
705706
"const child = spawn(process.execPath, [process.argv[2], process.argv[4], process.argv[5]], {",
706707
" stdio: 'ignore',",
707708
"});",
708709
"child.unref();",
709710
"process.on('SIGTERM', () => process.exit(0));",
710711
"setInterval(() => {}, 1000);",
712+
"fs.writeFileSync(process.argv[3], String(process.pid));",
711713
"",
712714
].join("\n"),
713715
);

0 commit comments

Comments
 (0)