Files
clide/lib/fd_check_io.dart
jpmschweitzerandClaude Fable 5 7b395c5a0a fix(testmode): skip the fd-inheritance probe when its helper is absent
The probe spawns a hand-built /tmp/checkfd binary that exists only on
machines where the T-438-era investigation ran; everywhere else it
failed the whole harness with a ProcessException. Absence is now an
explicit skip line, and the helper path is a named constant in both
the io and web-stub variants.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 18:48:48 +02:00

34 lines
1.2 KiB
Dart

/// FFI fd-inheritance probe for the testmode harness (T-438 web fence, D-100).
///
/// Desktop-only — [test_app.dart] selects [fd_check_stub.dart] on web so the
/// `dart:ffi` / `package:ffi` / libc imports stay out of the wasm graph.
library;
import 'dart:convert';
import 'dart:ffi' as ffi;
import 'dart:io';
import 'package:ffi/ffi.dart' as pkg_ffi;
import 'src/pty/ffi/libc.dart' as libc;
/// The hand-built helper binary the probe spawns. Not part of the repo — the
/// harness skips this probe when it is absent.
const fdCheckHelperPath = '/tmp/checkfd';
/// Probe whether `Process.start` inherits socket fds (the macOS question the
/// testmode harness answers). Returns a human-readable result line.
Future<String> fdInheritanceCheck() async {
final sv = pkg_ffi.calloc<ffi.Int32>(2);
libc.socketpair(1, 1, 0, sv); // AF_UNIX, SOCK_STREAM
final parent = sv[0];
final child = sv[1];
pkg_ffi.calloc.free(sv);
final proc = await Process.start(fdCheckHelperPath, [], environment: {...Platform.environment, 'PTYC_SOCK_FD': '$child'});
final stderr = await proc.stderr.transform(utf8.decoder).join();
final exit = await proc.exitCode;
libc.close(parent);
libc.close(child);
return 'exit=$exit stderr=${stderr.trim()}';
}