MCPcopy
hub / github.com/callstack/agent-device / runCmdDetachedMonitored

Function runCmdDetachedMonitored

src/utils/exec.ts:328–357  ·  view source on GitHub ↗
(
  cmd: string,
  args: string[],
  options: ExecDetachedOptions = {},
)

Source from the content-addressed store, hash-verified

326}
327
328export function runCmdDetachedMonitored(
329 cmd: string,
330 args: string[],
331 options: ExecDetachedOptions = {},
332): ExecDetachedProcess {
333 const executable = normalizeExecutableCommand(cmd);
334 const child = spawn(executable, args, {
335 cwd: options.cwd,
336 env: options.env,
337 stdio: options.stdio ?? 'ignore',
338 detached: true,
339 windowsHide: true,
340 shell: false,
341 });
342 const pid = child.pid ?? 0;
343 const exited = new Promise<ExecDetachedExit>((resolve) => {
344 child.once('error', (err) => {
345 resolve({ pid, error: err.message });
346 });
347 child.once('exit', (code, signal) => {
348 resolve({
349 pid,
350 ...(typeof code === 'number' ? { exitCode: code } : {}),
351 ...(signal ? { signal } : {}),
352 });
353 });
354 });
355 child.unref();
356 return { pid, exited };
357}
358
359export function runCmdBackground(
360 cmd: string,

Callers 2

startDaemonFunction · 0.90
runCmdDetachedFunction · 0.85

Calls 2

resolveFunction · 0.70

Tested by

no test coverage detected