Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAmend RFC 517: Add material on std::process #579
Conversation
aturon
referenced this pull request
Jan 13, 2015
Merged
RFC: io and os reform: initial skeleton #517
This comment has been minimized.
This comment has been minimized.
abonander
commented
Jan 13, 2015
|
Can It would be nice (if a bit verbose) if the |
alexcrichton
reviewed
Jan 13, 2015
| * `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. |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jan 13, 2015
Member
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).
alexcrichton
reviewed
Jan 13, 2015
| `Box<Writer+Send>` as appropriate. This effectively hides the internal | ||
| 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. |
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jan 13, 2015
Member
Taking another look at the windows implementation, it looks like the only common denominator is signal_kill as both exit/kill are canonicalized to TerminateProcess.
The signal_exit function may wish to live on a unix extension trait for now, and we can perhaps add a windows implementation at a future date.
This comment has been minimized.
This comment has been minimized.
jminer
Jan 14, 2015
Since Windows doesn't really have signals, I would like signal_kill renamed to kill. Seeing any reference to signals on Windows seems foreign to me.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nodakai
Jan 15, 2015
@alexcrichton It's fine to map SIGKILL to TerminateProcess(), but the common strategy to port SIGINT/SIGBREAK to Windows seems to be to use Win32 API GenerateConsoleCtrlEvent(). My understanding is that cmd.exe calls this API when we hit Ctrl-C on it. What's called "console event" in Win32 API also supports installation of arbitrary "handlers." The drawback is it is restricted to processes sharing the same "console."
See also:
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jan 15, 2015
Member
Oh nice, thanks for the pointers @nodakai! The restriction about processes sharing the same console is a little worrying, but I think I'd be fine with providing both variants with this semi-close equivalent.
I'd also be fine tweaking the names, @jminer has a good point that "signal" is inherently unix-biased.
This comment has been minimized.
This comment has been minimized.
|
@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). |
nagisa
reviewed
Jan 13, 2015
| * 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 |
This comment has been minimized.
This comment has been minimized.
nagisa
Jan 13, 2015
Contributor
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.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Jan 13, 2015
Member
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.
This comment has been minimized.
This comment has been minimized.
d3zd3z
commented
Jan 13, 2015
|
+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 |
quantheory
reviewed
Jan 15, 2015
| command to detached mode). | ||
|
|
||
| The `stdin`, `stdout`, `stderr` methods will undergo a more | ||
| significant change. By default, the corresponding options we be |
This comment has been minimized.
This comment has been minimized.
quantheory
reviewed
Jan 15, 2015
| * Rename `ProcessOuptput` to `Output` | ||
| * Rename `ProcessExit` to `ExitStatus`, and hide its | ||
| representation. Remove `matches_exit_status`, and add a `status` | ||
| method yielding an `Option<i32> |
This comment has been minimized.
This comment has been minimized.
quantheory
reviewed
Jan 15, 2015
|
|
||
| There are also a few other related changes to the module: | ||
|
|
||
| * Rename `ProcessOuptput` to `Output` |
This comment has been minimized.
This comment has been minimized.
nrc
assigned
aturon
Jan 15, 2015
kjpgit
reviewed
Jan 26, 2015
| 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`. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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 |
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton got it. Thanks. |
alexcrichton
referenced this pull request
Jan 28, 2015
Closed
Make child process InheritFd by default #755
This comment has been minimized.
This comment has been minimized.
|
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! |
aturon
added some commits
Jan 13, 2015
aturon
force-pushed the
aturon:io-process
branch
from
17f0ef7
to
2afff0e
Feb 3, 2015
This comment has been minimized.
This comment has been minimized.
l0kod
commented
Feb 8, 2015
|
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 {…}
} |
This comment has been minimized.
This comment has been minimized.
kjpgit
commented
Feb 8, 2015
|
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
|
aturon
added a commit
to aturon/rust
that referenced
this pull request
Feb 9, 2015
This comment has been minimized.
This comment has been minimized.
l0kod
commented
Feb 10, 2015
|
Is there any way to execute some safe code after a fork? A pre-exec hook would be very handy. |
This comment has been minimized.
This comment has been minimized.
l0kod
commented
Feb 10, 2015
|
Well, I think a pre-exec hook would be unsafe anyway, so an |
aturon commentedJan 13, 2015
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