Skip to content

Commit 1806cae

Browse files
committed
Review feedback: split inherit_stdin_stdout, and add corresponding options for the debug component.
1 parent 647853b commit 1806cae

2 files changed

Lines changed: 36 additions & 8 deletions

File tree

crates/cli-flags/src/lib.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,15 @@ wasmtime_option_group! {
280280
/// component. May be specified multiple times.
281281
#[serde(default)]
282282
pub arg: Vec<String>,
283+
/// Allow the debugger component to inherit stdin.Off by
284+
/// default.
285+
pub stdin: Option<bool>,
286+
/// Allow the debugger component to inherit stdout. Off by
287+
/// default.
288+
pub stdout: Option<bool>,
289+
/// Allow the debugger component to inherit stderr. Off by
290+
/// default.
291+
pub stderr: Option<bool>,
283292
}
284293

285294
enum Debug {
@@ -498,9 +507,12 @@ wasmtime_option_group! {
498507
///
499508
/// This option can be further overwritten with `--env` flags.
500509
pub inherit_env: Option<bool>,
501-
/// Inherit stdin/stdout from the parent process. On by
502-
/// default.
503-
pub inherit_stdin_stdout: Option<bool>,
510+
/// Inherit stdin from the parent process. On by default.
511+
pub inherit_stdin: Option<bool>,
512+
/// Inherit stdout from the parent process. On by default.
513+
pub inherit_stdout: Option<bool>,
514+
/// Inherit stderr from the parent process. On by default.
515+
pub inherit_stderr: Option<bool>,
504516
/// Pass a wasi config variable to the program.
505517
#[serde(skip)]
506518
pub config_var: Vec<KeyValuePair>,

src/commands/run.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,19 @@ impl RunCommand {
106106
// Explicitly permit TCP sockets for the debugger-main environment.
107107
debugger_run.run.common.wasi.tcp = Some(true);
108108
debugger_run.run.common.wasi.inherit_network = Some(true);
109-
// Do not inherit stdin/stdout (stderr is always
110-
// inherited) in the debugger-main environment.
111-
debugger_run.run.common.wasi.inherit_stdin_stdout = Some(false);
109+
// Copy over stdin/stdout/stderr inheritance settings,
110+
// except default to `false` for the debugger (so it
111+
// doesn't interfere with the debuggee's CLI interface, if
112+
// any). We expect most debug components will serve an
113+
// interface over the network; for those that want a TUI,
114+
// their setup instructions can instruct the user to set
115+
// these flags as needed.
116+
debugger_run.run.common.wasi.inherit_stdin =
117+
Some(self.run.common.debug.stdin.unwrap_or(false));
118+
debugger_run.run.common.wasi.inherit_stdout =
119+
Some(self.run.common.debug.stdout.unwrap_or(false));
120+
debugger_run.run.common.wasi.inherit_stderr =
121+
Some(self.run.common.debug.stderr.unwrap_or(false));
112122
Ok(Some(debugger_run))
113123
} else {
114124
Ok(None)
@@ -1244,8 +1254,14 @@ impl RunCommand {
12441254
builder.args(&self.compute_argv()?)?;
12451255

12461256
builder.inherit_stderr();
1247-
if self.run.common.wasi.inherit_stdin_stdout.unwrap_or(true) {
1248-
builder.inherit_stdin().inherit_stdout();
1257+
if self.run.common.wasi.inherit_stdin.unwrap_or(true) {
1258+
builder.inherit_stdin();
1259+
}
1260+
if self.run.common.wasi.inherit_stdout.unwrap_or(true) {
1261+
builder.inherit_stdout();
1262+
}
1263+
if self.run.common.wasi.inherit_stderr.unwrap_or(true) {
1264+
builder.inherit_stderr();
12491265
}
12501266

12511267
if self.run.common.wasi.inherit_env == Some(true) {

0 commit comments

Comments
 (0)