MCPcopy
hub / github.com/codeaashu/claude-code / spawnDetached

Function spawnDetached

src/utils/deepLink/terminalLauncher.ts:476–499  ·  view source on GitHub ↗

* Spawn a terminal detached so the handler process can exit without * waiting for the terminal to close. Resolves false on spawn failure * (ENOENT, EACCES) rather than crashing.

(
  command: string,
  args: string[],
  opts: { cwd?: string; windowsVerbatimArguments?: boolean } = {},
)

Source from the content-addressed store, hash-verified

474 * (ENOENT, EACCES) rather than crashing.
475 */
476function spawnDetached(
477 command: string,
478 args: string[],
479 opts: { cwd?: string; windowsVerbatimArguments?: boolean } = {},
480): Promise<boolean> {
481 return new Promise<boolean>(resolve => {
482 const child = spawn(command, args, {
483 detached: true,
484 stdio: 'ignore',
485 cwd: opts.cwd,
486 windowsVerbatimArguments: opts.windowsVerbatimArguments,
487 })
488 child.once('error', err => {
489 logForDebugging(`Failed to spawn ${command}: ${err.message}`, {
490 level: 'error',
491 })
492 void resolve(false)
493 })
494 child.once('spawn', () => {
495 child.unref()
496 void resolve(true)
497 })
498 })
499}
500
501/**
502 * Build a single-quoted POSIX shell command string. ONLY used by the

Callers 2

launchLinuxTerminalFunction · 0.85
launchWindowsTerminalFunction · 0.85

Calls 3

spawnFunction · 0.85
logForDebuggingFunction · 0.85
resolveFunction · 0.50

Tested by

no test coverage detected