An open-source, self-hosted system for apps built with web technologies.
Preserve process transport on Windows
zohayrslileheeefecbfc1e4
diff --git a/source/libs/process-tree.ts b/source/libs/process-tree.tsindex e9b7f39..bb0a139 100644--- a/source/libs/process-tree.ts+++ b/source/libs/process-tree.ts@@ -2,6 +2,10 @@ import { ChildProcess } from "node:child_process"const terminationGrace = 1_000+// POSIX detachment creates the process group we supervise; Windows detachment+// creates a separate console and breaks the inherited pipes and IPC channel.+export const detachedProcessTree = process.platform !== "win32"+/** The complete operating-system process tree beneath one child command. */export default class ProcessTree {diff --git a/source/server/core/server-runtime/command.ts b/source/server/core/server-runtime/command.tsindex d6a6b23..50b6470 100644--- a/source/server/core/server-runtime/command.ts+++ b/source/server/core/server-runtime/command.ts@@ -1,4 +1,4 @@-import ProcessTree from "@libs/process-tree"+import ProcessTree, { detachedProcessTree } from "@libs/process-tree"import type { ServerRuntime, ServerRuntimeEnding, Stream } from "../server-runtime"import messagepack from "@the-link/messagepack"import { spawn, type ChildProcess } from "node:child_process"@@ -19,7 +19,7 @@ export default class CommandServerRuntime implements ServerRuntime {this.child = spawn(command, {shell: true,- detached: true,+ detached: detachedProcessTree,cwd: directory,stdio: ["ignore", "pipe", "pipe", "ipc"],serialization: "advanced",diff --git a/source/server/core/shell.ts b/source/server/core/shell.tsindex edaa294..537adbc 100644--- a/source/server/core/shell.ts+++ b/source/server/core/shell.ts@@ -1,7 +1,7 @@import { spawn } from "node:child_process"import { homedir } from "node:os"import type { ShellEvent, ShellOptions } from "@phreshos/core"-import ProcessTree from "@libs/process-tree"+import ProcessTree, { detachedProcessTree } from "@libs/process-tree"type Queued = Readonly<{event: ShellEvent@@ -46,7 +46,7 @@ export default function shell(command: string, options: ShellOptions = {}): Asyn}const child = spawn(input.command, {shell: true,- detached: true,+ detached: detachedProcessTree,cwd: input.cwd,env: { ...process.env, ...input.env },stdio: ["ignore", "pipe", "pipe"]