MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / spawnDetached

Function spawnDetached

apps/cli/src/daemon.ts:143–166  ·  view source on GitHub ↗
(input: {
  readonly command: string;
  readonly args: ReadonlyArray<string>;
  readonly env: Record<string, string | undefined>;
})

Source from the content-addressed store, hash-verified

141// ---------------------------------------------------------------------------
142
143export const spawnDetached = (input: {
144 readonly command: string;
145 readonly args: ReadonlyArray<string>;
146 readonly env: Record<string, string | undefined>;
147}): Effect.Effect<SpawnedDetachedProcess, Error> =>
148 Effect.try({
149 try: () => {
150 const child = spawn(input.command, [...input.args], {
151 detached: true,
152 stdio: "ignore",
153 env: input.env,
154 });
155 child.unref();
156 if (typeof child.pid !== "number") {
157 child.kill();
158 throw new Error("Failed to spawn daemon process: child pid was not assigned");
159 }
160 return { pid: child.pid };
161 },
162 catch: (cause) =>
163 cause instanceof Error
164 ? cause
165 : new Error(`Failed to spawn daemon process: ${String(cause)}`),
166 });
167
168const signalPid = (pid: number): Effect.Effect<void, Error> =>
169 Effect.try({

Callers 2

daemon.test.tsFile · 0.90
spawnDaemonAsLockHolderFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected