()
| 991 | } |
| 992 | |
| 993 | function stopAgentDevice() { |
| 994 | const pids = agentDevicePids(); |
| 995 | for (const pid of pids) { |
| 996 | try { |
| 997 | process.kill(pid, "SIGTERM"); |
| 998 | } catch { |
| 999 | // Process may already be gone. |
| 1000 | } |
| 1001 | } |
| 1002 | if (pids.length > 0) { |
| 1003 | spawnSync("sleep", ["0.5"]); |
| 1004 | } |
| 1005 | for (const pid of agentDevicePids()) { |
| 1006 | try { |
| 1007 | process.kill(pid, "SIGKILL"); |
| 1008 | } catch { |
| 1009 | // Process may already be gone. |
| 1010 | } |
| 1011 | } |
| 1012 | } |
| 1013 | |
| 1014 | function agentDevicePids() { |
| 1015 | const ps = spawnSync("ps", ["-axo", "pid=,command="], { |
no test coverage detected