()
| 207 | |
| 208 | |
| 209 | def get_sergate_pid(): |
| 210 | try: |
| 211 | with open(SERGATE_PID_FILE, "r", encoding="utf-8") as f: |
| 212 | pid = int(f.read().strip()) |
| 213 | os.kill(pid, 0) |
| 214 | return pid |
| 215 | except Exception: |
| 216 | pass |
| 217 | proc_dir = "/proc" |
| 218 | if not os.path.isdir(proc_dir): |
| 219 | return None |
| 220 | for name in os.listdir(proc_dir): |
| 221 | if not name.isdigit(): |
| 222 | continue |
| 223 | try: |
| 224 | with open(os.path.join(proc_dir, name, "cmdline"), "rb") as f: |
| 225 | cmdline = f.read().replace(b"\x00", b" ").decode("utf-8", "ignore") |
| 226 | except Exception: |
| 227 | continue |
| 228 | if "sergate" in cmdline: |
| 229 | return int(name) |
| 230 | return None |
| 231 | |
| 232 | |
| 233 | def signal_sergate(sig): |
no outgoing calls
no test coverage detected