diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2020-04-15 20:43:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-15 20:43:19 -0400 |
commit | fab0204cbf20cc1be7874266325bf258fe0ecaca (patch) | |
tree | c67b3febde254ea36122966aadf13dfb62b67a0e /cli/ops/process.rs | |
parent | 7cfd094359f7f94573b084328ad1a956dd70005d (diff) |
Make writeSync, readSync, seekSync, openSync, isatty proper synchronous syscalls (#4762)
Diffstat (limited to 'cli/ops/process.rs')
-rw-r--r-- | cli/ops/process.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/cli/ops/process.rs b/cli/ops/process.rs index 096b09bd0..980147832 100644 --- a/cli/ops/process.rs +++ b/cli/ops/process.rs @@ -26,13 +26,15 @@ fn clone_file(rid: u32, state: &State) -> Result<std::fs::File, OpError> { .resource_table .get_mut::<StreamResourceHolder>(rid) .ok_or_else(OpError::bad_resource_id)?; - let file = match repr_holder.resource { - StreamResource::FsFile(ref mut file, _) => file, - _ => return Err(OpError::bad_resource_id()), - }; - let tokio_file = futures::executor::block_on(file.try_clone())?; - let std_file = futures::executor::block_on(tokio_file.into_std()); - Ok(std_file) + match repr_holder.resource { + StreamResource::FsFile(Some((ref mut file, _))) => { + let tokio_file = futures::executor::block_on(file.try_clone())?; + let std_file = futures::executor::block_on(tokio_file.into_std()); + Ok(std_file) + } + StreamResource::FsFile(None) => Err(OpError::resource_unavailable()), + _ => Err(OpError::bad_resource_id()), + } } fn subprocess_stdio_map(s: &str) -> std::process::Stdio { |