diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-25 17:14:07 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-26 00:20:05 +0900 |
| commit | 0dd510dbc3a5b6e888abcc104ae8c4a4eeb1e42b (patch) | |
| tree | 8b6e7663c82bd7c4bbe91f4594940aa780376d77 /crates/shirabe-php-shim/src/fs.rs | |
| parent | 6c137a28151f5ef05c9e22d3232e9ba7b81f6abe (diff) | |
| download | php-shirabe-0dd510dbc3a5b6e888abcc104ae8c4a4eeb1e42b.tar.gz php-shirabe-0dd510dbc3a5b6e888abcc104ae8c4a4eeb1e42b.tar.zst php-shirabe-0dd510dbc3a5b6e888abcc104ae8c4a4eeb1e42b.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim/src/fs.rs')
| -rw-r--r-- | crates/shirabe-php-shim/src/fs.rs | 8 |
1 files changed, 7 insertions, 1 deletions
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<String> { 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; } |
