| 1012 | } |
| 1013 | |
| 1014 | function agentDevicePids() { |
| 1015 | const ps = spawnSync("ps", ["-axo", "pid=,command="], { |
| 1016 | encoding: "utf8", |
| 1017 | maxBuffer: 8 * 1024 * 1024, |
| 1018 | }); |
| 1019 | if (ps.status !== 0) { |
| 1020 | return []; |
| 1021 | } |
| 1022 | const pids = []; |
| 1023 | const ownPid = process.pid; |
| 1024 | for (const line of ps.stdout.split("\n")) { |
| 1025 | const match = line.trim().match(/^(\d+)\s+(.*)$/); |
| 1026 | if (!match) { |
| 1027 | continue; |
| 1028 | } |
| 1029 | const pid = Number(match[1]); |
| 1030 | const command = match[2]; |
| 1031 | if (pid === ownPid) { |
| 1032 | continue; |
| 1033 | } |
| 1034 | if ( |
| 1035 | command.includes("agent-device") && |
| 1036 | (command.includes("internal/service") || |
| 1037 | command.includes("AgentDeviceRunnerUITests") || |
| 1038 | command.includes("agent-device-service")) |
| 1039 | ) { |
| 1040 | pids.push(pid); |
| 1041 | } |
| 1042 | } |
| 1043 | return pids; |
| 1044 | } |
| 1045 | |
| 1046 | function selectBootedIphoneUdid() { |
| 1047 | const result = run(simdeckBin, ["list", "--format", "compact-json"], { |