Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure stdio using std::process::Command builder #2

Open
ebkalderon opened this issue Nov 24, 2019 · 2 comments
Open

Configure stdio using std::process::Command builder #2

ebkalderon opened this issue Nov 24, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@ebkalderon
Copy link
Owner

Because we cannot extract and inspect the std::process::Stdio from the std::process::Command builder passed to Sandbox::spawn(), we cannot determine at runtime whether to pipe or inherit our stdin/stdout/stderr descriptors. As a result, Bastille currently defaults to Stdio::inherit() for all three by default and can be switched to piped stdin/stdout/stderr if compiled with the piped Cargo feature.

This is not at all ideal, but fixing this requires resolving rust-lang/rust#44434 and also finding some way to inspect whether a given std::process::Stdio is set to "inherit," "piped," or "null."

An alternative but less desirable approach would be to implement our own in-crate Stdio type like how we currently do with Child. Still, it would be best to reuse as many std::process types as possible when configuring and spawning commands in Bastille.

@ebkalderon ebkalderon added the enhancement New feature or request label Nov 24, 2019
@ebkalderon
Copy link
Owner Author

Documented the current limitation in commit a252d44.

@ebkalderon
Copy link
Owner Author

At the time of writing, we use Cargo features to set the stdio configuration for the launched process. This is not ideal and will be replaced by a dedicated Rust API in the future, but the approach works well enough for now. The following modes are available, as defined in the Cargo.toml:

Feature stdin stdout stderr
default Inherit Inherit Inherit
piped Piped Piped Piped
piped-merged Piped Piped Merged with stdout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant