-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Amend RFC 517: Add material on std::process #579
Conversation
Can It would be nice (if a bit verbose) if the |
* `stdin`, `stdout` and `stderr` will be retained as public fields, | ||
but their types will change to `Box<Reader+Send>` or | ||
`Box<Writer+Send>` as appropriate. This effectively hides the internal | ||
pipe infrastructure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was mentioned on the previous RFC, but it may be better to use concrete types here to allow addition of extension traits for platform-specific APIs (such as getting the file descriptor on unix).
@cybergeek94
Indeed! The plan here is to move these unix-only functions into an extension trait inside of
I think this came up on the original RFC, but I've recommended that we move to concrete types instead of trait objects to allow future extensions to be added to them in the future (such as cloning). |
* Rename `cwd` to `current_dir`, take `AsPath`. | ||
* Rename `spawn` to `run` | ||
* Move `uid` and `gid` to an extension trait in `os::unix` | ||
* Make `detached` take a `bool` (rather than always setting the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice if this had the similar API as Thread. i.e. keep spawn
which spawns a detached process and add scoped
which creates a bound/attached process that you can detach any time later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This form of detached
actually has a somewhat different semantic meaning than the detached for threads, which is good to point out! For threads you can simply choose at some point during their lifecycle to detach, but for processes there's 2 decisions to make:
- When spawning, the detached flag affects how the child process is spawned.
- When dropping a
Child
, whether or not towait()
for the child.
I think that the use case of spawning threads and processes is different enough to keep the APIs different, but we may want to explore various names.
+1 on the std connectors inheriting by default for many invocation cases. One problem I currently have (that looks unchanged) is that all of the fields of |
command to detached mode). | ||
|
||
The `stdin`, `stdout`, `stderr` methods will undergo a more | ||
significant change. By default, the corresponding options we be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/we/will/
pipe infrastructure. | ||
* The `kill` method is dropped, and `id` and `signal` will move to `os::platform` extension traits. | ||
* `signal_exit`, `signal_kill`, `wait`, and `forget` will all stay as they are. | ||
* `wait_with_output` will take `&self`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you mean &mut self?
As far as I can tell, this proposal doesn't allow for piping directly from one Child to another. Is there any reason the the |
@Stebalien The outline of this RFC is largely geared towards categorizing today's implementation as well as ensuring that it has ample room to grow in the future. For example today piping from one child to another is difficult to do (requires mucking around with raw file descriptors). That's not to say that this RFC is saying it can't be done, however. The modifications to the |
@alexcrichton got it. Thanks. |
All: I've updated this RFC with a few minor fixes. The only substantial change is to not use trait objects for As to reading data out of Overall, there hasn't been a ton of feedback here, but I think that's largely because the current APIs are working well. This RFC will come up for a decision in the near future so if you have more feedback, please leave more comments! |
The However, a more flexible approach would be to add a pre-execution closure to the impl Command {
fn prepare<'a, T>(&'a mut self, prepare: T) -> &'a mut Command
where T: FnOnce() -> IoResult<()>, T: Send + 'a {…}
} |
running arbitrary code after a fork is not thread safe. On Sat, Feb 7, 2015 at 7:09 PM, Mickaël Salaün notifications@github.com
|
Is there any way to execute some safe code after a fork? A pre-exec hook would be very handy. |
Well, I think a pre-exec hook would be unsafe anyway, so an |
Per [RFC 579](rust-lang/rfcs#579), this commit adds a new `std::process` module. This module is largely based on the existing `std::old_io::process` module, but refactors the API to use `OsStr` and other new standards set out by IO reform. The existing module is not yet deprecated, to allow for the new API to get a bit of testing before a mass migration to it.
Per [RFC 579](rust-lang/rfcs#579), this commit adds a new `std::process` module. This module is largely based on the existing `std::old_io::process` module, but refactors the API to use `OsStr` and other new standards set out by IO reform. The existing module is not yet deprecated, to allow for the new API to get a bit of testing before a mass migration to it.
The IO reform RFC is being split into several semi-independent pieces, posted as PRs like this one.
This RFC amendment discusses
std::process
.Rendered