From 0dd510dbc3a5b6e888abcc104ae8c4a4eeb1e42b Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 25 Jun 2026 17:14:07 +0900 Subject: feat(shim): implement stream_select/stream_set_blocking via libc Add fcntl/select extern "C" declarations and a PhpResource::raw_fd seam so the symfony Process pipe loop can read a live child's stdout/stderr. Fix fread on a non-blocking fd (WouldBlock -> "") and the Process null-cwd default. Real subprocess output capture now works; un-ignore the process_executor tests. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe-php-shim/src/fs.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/shirabe-php-shim/src/fs.rs') diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs index 5558f58..2fb0dc5 100644 --- a/crates/shirabe-php-shim/src/fs.rs +++ b/crates/shirabe-php-shim/src/fs.rs @@ -343,7 +343,13 @@ pub fn fread(stream: &PhpResource, length: i64) -> Option { return None; } let mut buf = vec![0u8; cap]; - let n = state.backing.as_rws().read(&mut buf).ok()?; + let n = match state.backing.as_rws().read(&mut buf) { + Ok(n) => n, + // A non-blocking stream with no data ready is not an error in PHP: fread() returns + // the empty string and feof() stays false. std surfaces this as WouldBlock. + Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => return Some(String::new()), + Err(_) => return None, + }; if cap > 0 && n == 0 { state.eof = true; } -- cgit v1.3.1