killDetachedWatcher function

Future<void> killDetachedWatcher(
  1. File yamlFile
)

kill all watchers for the given YAML file

Implementation

Future<void> killDetachedWatcher(File yamlFile) async {
  final pids = await _getWatcherPids(yamlFile);
  if (pids.isEmpty) {
    print('No watcher running for ${yamlFile.path}');
    return;
  }

  for (final pid in pids) {
    try {
      Process.killPid(pid);
      print('💀 Killed watcher PID: $pid');
    } catch (_) {
      print('❌ Failed to kill watcher PID: $pid');
    }
  }
}