diff options
author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-10-23 21:13:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-23 21:13:30 -0700 |
commit | 7c57105cc41cf16c5f48f85d85c7fd9bd3bb4d1f (patch) | |
tree | 3263cc60139b71b340c93e988128d8ce5aca6e6f /tests/specs/node/child_process_extra_pipes/test-pipe/src/main.rs | |
parent | fa49fd404be82daf8ac7228bf54e780135f67b17 (diff) |
fix(ext/node): only set our end of child process pipe to nonblocking mode (#26495)
Fixes playwright on linux, as reported in
https://github.com/denoland/deno/issues/16899#issuecomment-2378268454.
The issue was that we were opening the socket in nonblocking mode, which
meant that subprocesses trying to use it would get a `EWOULDBLOCK` error
(unexpectedly). The fix here is to only set nonblocking mode on our end
(which we need to use asynchronously)
Diffstat (limited to 'tests/specs/node/child_process_extra_pipes/test-pipe/src/main.rs')
-rw-r--r-- | tests/specs/node/child_process_extra_pipes/test-pipe/src/main.rs | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/specs/node/child_process_extra_pipes/test-pipe/src/main.rs b/tests/specs/node/child_process_extra_pipes/test-pipe/src/main.rs index 192f82731..acc034830 100644 --- a/tests/specs/node/child_process_extra_pipes/test-pipe/src/main.rs +++ b/tests/specs/node/child_process_extra_pipes/test-pipe/src/main.rs @@ -1,12 +1,31 @@ +use std::fs::File; use std::io::prelude::*; use std::os::fd::FromRawFd; -use std::os::unix::net::UnixStream; fn main() { #[cfg(unix)] { - let mut stream = unsafe { UnixStream::from_raw_fd(4) }; + let mut pipe = unsafe { File::from_raw_fd(4) }; - stream.write_all(b"hello world\n").unwrap(); + let mut read = 0; + let mut buf = [0u8; 1024]; + loop { + if read > 4 { + assert_eq!(&buf[..5], b"start"); + break; + } + match pipe.read(&mut buf) { + Ok(n) => { + read += n; + } + Ok(0) => { + return; + } + Err(e) => { + eprintln!("GOT ERROR: {e:?}"); + } + } + } + pipe.write_all(b"hello world").unwrap(); } } |