diff --git a/Cargo.lock b/Cargo.lock index 820dafb0c..3b23fd683 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1319,6 +1319,10 @@ dependencies = [ "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "pipe" +version = "0.1.0" + [[package]] name = "pkg-config" version = "0.3.14" diff --git a/Cargo.toml b/Cargo.toml index b11e13340..8849a4918 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,7 @@ wasmer-wasi = { path = "lib/wasi", optional = true } kwasm-loader = { path = "lib/kwasm-loader" } [workspace] -members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "examples/kernel/hello_world", "examples/plugin-for-example"] +members = ["lib/clif-backend", "lib/singlepass-backend", "lib/runtime", "lib/runtime-abi", "lib/runtime-core", "lib/emscripten", "lib/spectests", "lib/win-exception-handler", "lib/runtime-c-api", "lib/llvm-backend", "lib/wasi", "lib/middleware-common", "lib/kwasm-loader", "examples/kernel/hello_world", "examples/pipe", "examples/plugin-for-example"] [build-dependencies] wabt = "0.7.2" diff --git a/examples/pipe/Cargo.toml b/examples/pipe/Cargo.toml new file mode 100644 index 000000000..50702bbb1 --- /dev/null +++ b/examples/pipe/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "pipe" +version = "0.1.0" +authors = ["Heyang Zhou "] +edition = "2018" + +[dependencies] diff --git a/examples/pipe/src/main.rs b/examples/pipe/src/main.rs new file mode 100644 index 000000000..5192c539a --- /dev/null +++ b/examples/pipe/src/main.rs @@ -0,0 +1,13 @@ +use std::io::{Read, Write}; + +fn main() { + let mut stdin = ::std::io::stdin(); + let mut stdout = ::std::io::stdout(); + let mut buf: Vec = vec![0; 512]; + let mut total: u64 = 0; + while total < 1048576u64 * 2048 { + let n = stdin.read(&mut buf).unwrap(); + stdout.write_all(&buf[..n]).unwrap(); + total += n as u64; + } +}