From c1c74ca54be72f0b066084185e777e2df98e452c Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 10 Sep 2019 16:10:16 -0700 Subject: [PATCH] Add a method for inhering the command-line arguments from the host. --- src/ctx.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ctx.rs b/src/ctx.rs index 580d04d575..66a2e12610 100644 --- a/src/ctx.rs +++ b/src/ctx.rs @@ -3,6 +3,7 @@ use crate::sys::dev_null; use crate::{host, Error, Result}; use std::borrow::Borrow; use std::collections::HashMap; +use std::env; use std::ffi::CString; use std::fs::File; use std::path::{Path, PathBuf}; @@ -45,6 +46,11 @@ impl WasiCtxBuilder { Ok(self) } + /// Inherit the command-line arguments from the host process. + pub fn inherit_args(self) -> Result { + self.args(env::args()) + } + pub fn inherit_stdio(mut self) -> Result { self.fds.insert(0, FdEntry::duplicate_stdin()?); self.fds.insert(1, FdEntry::duplicate_stdout()?);