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

Function stopProcessForTakeover

src/utils/process-identity.ts:99–112  ·  view source on GitHub ↗
(
  pid: number,
  options: {
    termTimeoutMs: number;
    killTimeoutMs: number;
    expectedStartTime?: string;
  },
)

Source from the content-addressed store, hash-verified

97}
98
99export async function stopProcessForTakeover(
100 pid: number,
101 options: {
102 termTimeoutMs: number;
103 killTimeoutMs: number;
104 expectedStartTime?: string;
105 },
106): Promise<void> {
107 if (!isAgentDeviceDaemonProcess(pid, options.expectedStartTime)) return;
108 if (!trySignalProcess(pid, 'SIGTERM')) return;
109 if (await waitForProcessExit(pid, options.termTimeoutMs)) return;
110 if (!trySignalProcess(pid, 'SIGKILL')) return;
111 await waitForProcessExit(pid, options.killTimeoutMs);
112}

Calls 3

trySignalProcessFunction · 0.85
waitForProcessExitFunction · 0.70

Tested by 1

stopDaemonForStateDirFunction · 0.72