On this page

0224. Graceful FFI helper cleanup

A real interpreter trap test exited 101 while leaving the terminal raw because FramedChild unconditionally killed the helper, skipping its atexit restoration. An idle FFI helper now receives EOF on its request pipe and gets up to100ms to exit normally; after that it is killed and reaped as before. Other framed helpers retain immediate teardown. This changes resource cleanup, not language semantics or the wire protocol. Native crashes and externally forced termination still cannot promise cleanup. The maintained real-PTY trap fixture covers both the C program's atexit and interpreter helper teardown.

The helper defines HRT_INTERP_FFI_HOST for trusted shims and ignores SIGPIPE on its reply channel so parent loss reaches normal exit cleanup. Blocking tty and daemon waits watch their synchronous request pipe for parent EOF, restoring owned resources before returning. This does not create a guardian thread or make arbitrary blocked native code cancellable. Native child launchers restore default SIGPIPE before exec. Daemon termination signals are data handled by its normal cleanup path; client disconnect still does not cancel workers.