diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2016-01-24 21:14:56 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2016-01-25 17:48:27 -0800 |
| commit | fee457d3af355f24ef321ea7250e968638f403c8 (patch) | |
| tree | f18d89060efa06320b851137933db8b87e99934d /src/libstd/io/stdio.rs | |
| parent | 6866f1361debf5857856ff95eeee806bb7bea738 (diff) | |
| download | rust-fee457d3af355f24ef321ea7250e968638f403c8.tar.gz rust-fee457d3af355f24ef321ea7250e968638f403c8.zip | |
std: Fix some behavior without stdio handles
On all platforms, reading from stdin where the actual stdin isn't present should return 0 bytes as having been read rather than the entire buffer. On Windows, handle the case where we're inheriting stdio handles but one of them isn't present. Currently the behavior is to fail returning an I/O error but instead this commit corrects it to detecting this situation and propagating the non-set handle. Closes #31167
Diffstat (limited to 'src/libstd/io/stdio.rs')
| -rw-r--r-- | src/libstd/io/stdio.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 79091fd3d6b..cd2d5e52462 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -112,7 +112,7 @@ impl<W: io::Write> io::Write for Maybe<W> { impl<R: io::Read> io::Read for Maybe<R> { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { match *self { - Maybe::Real(ref mut r) => handle_ebadf(r.read(buf), buf.len()), + Maybe::Real(ref mut r) => handle_ebadf(r.read(buf), 0), Maybe::Fake => Ok(0) } } |
