fix(process): align provider detach with configured platform

This commit is contained in:
morluto
2026-10-06 02:26:15 +08:00
parent a574b744b8
commit 3fff74fb5b
2 changed files with 51 additions and 0 deletions
+1
View File
@@ -131,6 +131,7 @@ export class GhidraHeadlessLauncher implements GhidraLauncher {
// the per-process run token remain the cleanup authority.
expectedCommand: null,
windowsVerbatimArguments: platform === "win32",
platform,
env: ghidraLaunchEnvironment(paths, this.options.javaHome, platform),
});
await writeFileAtomic(
@@ -515,3 +515,53 @@ describe("provider process spawning primitives", () => {
).rejects.toMatchObject({ code: "ENOENT" });
});
});
describe("provider process configured-platform spawning", () => {
it.skipIf(process.platform === "win32")(
"uses the configured platform when establishing process-group identity",
async () => {
const windowsConfigured = await spawnOwnedProviderProcess({
command: process.execPath,
arguments: [processFixturePath, "graceful"],
runId: "provider-process-configured-win32-run",
platform: "win32",
});
const posixConfigured = await spawnOwnedProviderProcess({
command: process.execPath,
arguments: [processFixturePath, "graceful"],
runId: "provider-process-configured-posix-run",
platform: "linux",
});
try {
await Promise.all([
waitForProviderProcessReady(windowsConfigured.process),
waitForProviderProcessReady(posixConfigured.process),
]);
await expect(
observeOwnedProcessLineage(windowsConfigured.ownership),
).resolves.toMatchObject({
status: "unavailable",
reason: "owned launcher process-group identity did not match",
launcherPid: windowsConfigured.process.pid,
});
await expect(
observeOwnedProcessLineage(posixConfigured.ownership),
).resolves.toMatchObject({
status: "verified",
lineage: {
runId: "provider-process-configured-posix-run",
launcherPid: posixConfigured.process.pid,
launcherParentPid: process.pid,
processGroupId: posixConfigured.process.pid,
descendants: [],
},
});
} finally {
await Promise.all([
stopProviderProcessFixture(windowsConfigured.process),
stopProviderProcessFixture(posixConfigured.process),
]);
}
},
);
});