MCPcopy Index your code
hub / github.com/callstack/agent-device / watchCommandAbort

Function watchCommandAbort

src/utils/exec.ts:702–724  ·  view source on GitHub ↗
(
  child: ChildProcess,
  options: Pick<ExecOptions, 'detached' | 'signal'>,
)

Source from the content-addressed store, hash-verified

700}
701
702function watchCommandAbort(
703 child: ChildProcess,
704 options: Pick<ExecOptions, 'detached' | 'signal'>,
705): { readonly didAbort: boolean; dispose: () => void } {
706 let didAbort = false;
707 const onAbort = () => {
708 didAbort = true;
709 killProcessTree(child, options.detached);
710 };
711 if (options.signal?.aborted) {
712 onAbort();
713 } else {
714 options.signal?.addEventListener('abort', onAbort, { once: true });
715 }
716 return {
717 get didAbort() {
718 return didAbort;
719 },
720 dispose: () => {
721 options.signal?.removeEventListener('abort', onAbort);
722 },
723 };
724}
725
726function killProcessTree(child: ChildProcess, detached: boolean | undefined): void {
727 if (detached && child.pid && process.platform !== 'win32') {

Callers 2

runSpawnedCommandFunction · 0.85
runCmdBackgroundFunction · 0.85

Calls 1

onAbortFunction · 0.70

Tested by

no test coverage detected