MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / watchman_available

Function watchman_available

atomic-agent/src/watcher/mod.rs:297–323  ·  view source on GitHub ↗

Probe whether a Watchman daemon is reachable (`watchman get-sockname`). CB-13D ::24 R4: the probe is BOUNDED — a stuck (never-exiting) daemon is killed after the timeout and reports unavailable, so no `create_watcher` caller (ordinary reconcile/switch or managed-agent setup) can hang behind an optional daemon that never answers. A missing binary or a failing socket query simply reports unavailabl

()

Source from the content-addressed store, hash-verified

295/// Never used as state authority — availability only selects which honest
296/// diagnostic the factory emits.
297fn watchman_available() -> bool {
298 use std::process::Stdio;
299 use std::time::{Duration, Instant};
300 const PROBE_TIMEOUT: Duration = Duration::from_millis(500);
301 let Ok(mut child) = std::process::Command::new("watchman")
302 .arg("get-sockname")
303 .stdout(Stdio::null())
304 .stderr(Stdio::null())
305 .spawn()
306 else {
307 return false;
308 };
309 let deadline = Instant::now() + PROBE_TIMEOUT;
310 loop {
311 match child.try_wait() {
312 Ok(Some(status)) => return status.success(),
313 Ok(None) if Instant::now() < deadline => {
314 std::thread::sleep(Duration::from_millis(25));
315 }
316 _ => {
317 let _ = child.kill();
318 let _ = child.wait();
319 return false;
320 }
321 }
322 }
323}
324
325/// Create a [`FileWatcher`] using the best available backend.
326///

Callers 1

create_watcher_with_tierFunction · 0.85

Calls 2

spawnMethod · 0.80
successMethod · 0.80

Tested by

no test coverage detected