Harden poller detection against matching the searching process itself
The harness and probe found pollers with a SUBSTRING search over /proc/<pid>/cmdline. That matches any process whose command line merely contains "--telegram-poller" -- including the very script doing the search.
It cost nothing in the harness, where poller_children() only ever inspects children of a specific courier pid and a measurement script is never one. It cost real confusion in ad-hoc whole-host scans: twice on 2026-08-04 a scan reported extra pollers on the live estate, and both times the extras were the bash/python process running the scan. I was one step from reporting a production incident that did not exist; re-measuring rather than reporting is what caught it.
Detection now requires the LAST argv element to be exactly the flag AND the executable to really be a courier binary. Same defect the worker guide warns about for pgrep -f, rediscovered in a home-grown scanner.
Harness 59/0 and the production-shape probe still pass with the stricter detector, so nothing was passing on a loose match.
repro/single_poller_harness.py | 14 +++++++++++---
repro/two_paths_probe.py | 12 +++++++++---
2 files changed, 20 insertions(+), 6 deletions(-)repro/single_poller_harness.pymodified
for c in child_pids(pid): try: with open(f"/proc/{c}/cmdline", "rb") as f: cmd = f.read().decode("utf-8", "replace") except (FileNotFoundError, ProcessLookupError, PermissionError): argv = f.read().decode("utf-8", "replace").rstrip("\0").split("\0") exe = os.readlink(f"/proc/{c}/exe") except (FileNotFoundError, ProcessLookupError, PermissionError, OSError): continue if "--telegram-poller" in cmd: # Match the LAST argv element exactly, and require the executable to # really be a courier. A substring search over cmdline matches any # process whose command line merely CONTAINS the flag -- including the # very script doing the search. That is the `pgrep -f` self-match # hazard, and it produced two phantom "extra poller" readings on # 2026-08-04 before it was caught. if argv and argv[-1] == "--telegram-poller" and \ os.path.basename(exe).startswith("courier"): found.append(c) return foundrepro/two_paths_probe.pymodified
break if ppid != pid: continue cmd = open(f"/proc/{e}/cmdline", "rb").read().decode("utf8", "replace") except (FileNotFoundError, ProcessLookupError, PermissionError): argv = open(f"/proc/{e}/cmdline", "rb").read().decode( "utf8", "replace").rstrip("\0").split("\0") exe = os.readlink(f"/proc/{e}/exe") except (FileNotFoundError, ProcessLookupError, PermissionError, OSError): continue if "--telegram-poller" in cmd: # Exact last-argv match AND a real courier executable: a substring # search matches the searching process itself (the `pgrep -f` # self-match hazard). if argv and argv[-1] == "--telegram-poller" and \ os.path.basename(exe).startswith("courier"): out.append(int(e)) return out