Skip to content

Commit 0f98e75

Browse files
committed
Runtime removal: refactor process
This patch continues the runtime removal by moving and refactoring the process implementation into the new `sys` module. Because this eliminates APIs in `libnative` and `librustrt`, it is a: [breaking-change] This functionality is likely to be available publicly, in some form, from `std` in the future.
1 parent 3d19548 commit 0f98e75

File tree

10 files changed

+1250
-176
lines changed

10 files changed

+1250
-176
lines changed

src/libnative/io/mod.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ use std::os;
2929
use std::rt::rtio::{mod, IoResult, IoError};
3030
use std::num;
3131

32-
// Local re-exports
33-
pub use self::process::Process;
34-
35-
// Native I/O implementations
36-
pub mod process;
37-
mod util;
38-
3932
#[cfg(any(target_os = "macos",
4033
target_os = "ios",
4134
target_os = "freebsd",
@@ -123,19 +116,6 @@ impl rtio::IoFactory for IoFactory {
123116
fn timer_init(&mut self) -> IoResult<Box<rtio::RtioTimer + Send>> {
124117
timer::Timer::new().map(|t| box t as Box<rtio::RtioTimer + Send>)
125118
}
126-
fn spawn(&mut self, cfg: rtio::ProcessConfig)
127-
-> IoResult<(Box<rtio::RtioProcess + Send>,
128-
Vec<Option<Box<rtio::RtioPipe + Send>>>)> {
129-
process::Process::spawn(cfg).map(|(p, io)| {
130-
(box p as Box<rtio::RtioProcess + Send>,
131-
io.into_iter().map(|p| p.map(|p| {
132-
box p as Box<rtio::RtioPipe + Send>
133-
})).collect())
134-
})
135-
}
136-
fn kill(&mut self, pid: libc::pid_t, signum: int) -> IoResult<()> {
137-
process::Process::kill(pid, signum)
138-
}
139119
#[cfg(unix)]
140120
fn tty_open(&mut self, fd: c_int, _readable: bool)
141121
-> IoResult<Box<rtio::RtioTTY + Send>> {

src/librustrt/rtio.rs

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -46,61 +46,6 @@ pub trait RemoteCallback {
4646
fn fire(&mut self);
4747
}
4848

49-
/// Data needed to spawn a process. Serializes the `std::io::process::Command`
50-
/// builder.
51-
pub struct ProcessConfig<'a> {
52-
/// Path to the program to run.
53-
pub program: &'a CString,
54-
55-
/// Arguments to pass to the program (doesn't include the program itself).
56-
pub args: &'a [CString],
57-
58-
/// Optional environment to specify for the program. If this is None, then
59-
/// it will inherit the current process's environment.
60-
pub env: Option<&'a [(&'a CString, &'a CString)]>,
61-
62-
/// Optional working directory for the new process. If this is None, then
63-
/// the current directory of the running process is inherited.
64-
pub cwd: Option<&'a CString>,
65-
66-
/// Configuration for the child process's stdin handle (file descriptor 0).
67-
/// This field defaults to `CreatePipe(true, false)` so the input can be
68-
/// written to.
69-
pub stdin: StdioContainer,
70-
71-
/// Configuration for the child process's stdout handle (file descriptor 1).
72-
/// This field defaults to `CreatePipe(false, true)` so the output can be
73-
/// collected.
74-
pub stdout: StdioContainer,
75-
76-
/// Configuration for the child process's stdout handle (file descriptor 2).
77-
/// This field defaults to `CreatePipe(false, true)` so the output can be
78-
/// collected.
79-
pub stderr: StdioContainer,
80-
81-
/// Any number of streams/file descriptors/pipes may be attached to this
82-
/// process. This list enumerates the file descriptors and such for the
83-
/// process to be spawned, and the file descriptors inherited will start at
84-
/// 3 and go to the length of this array. The first three file descriptors
85-
/// (stdin/stdout/stderr) are configured with the `stdin`, `stdout`, and
86-
/// `stderr` fields.
87-
pub extra_io: &'a [StdioContainer],
88-
89-
/// Sets the child process's user id. This translates to a `setuid` call in
90-
/// the child process. Setting this value on windows will cause the spawn to
91-
/// fail. Failure in the `setuid` call on unix will also cause the spawn to
92-
/// fail.
93-
pub uid: Option<uint>,
94-
95-
/// Similar to `uid`, but sets the group id of the child process. This has
96-
/// the same semantics as the `uid` field.
97-
pub gid: Option<uint>,
98-
99-
/// If true, the child process is spawned in a detached state. On unix, this
100-
/// means that the child is the leader of a new process group.
101-
pub detach: bool,
102-
}
103-
10449
pub struct LocalIo<'a> {
10550
factory: &'a mut IoFactory+'a,
10651
}
@@ -170,10 +115,6 @@ impl<'a> LocalIo<'a> {
170115

171116
pub trait IoFactory {
172117
fn timer_init(&mut self) -> IoResult<Box<RtioTimer + Send>>;
173-
fn spawn(&mut self, cfg: ProcessConfig)
174-
-> IoResult<(Box<RtioProcess + Send>,
175-
Vec<Option<Box<RtioPipe + Send>>>)>;
176-
fn kill(&mut self, pid: libc::pid_t, signal: int) -> IoResult<()>;
177118
fn tty_open(&mut self, fd: c_int, readable: bool)
178119
-> IoResult<Box<RtioTTY + Send>>;
179120
}
@@ -184,13 +125,6 @@ pub trait RtioTimer {
184125
fn period(&mut self, msecs: u64, cb: Box<Callback + Send>);
185126
}
186127

187-
pub trait RtioProcess {
188-
fn id(&self) -> libc::pid_t;
189-
fn kill(&mut self, signal: int) -> IoResult<()>;
190-
fn wait(&mut self) -> IoResult<ProcessExit>;
191-
fn set_timeout(&mut self, timeout: Option<u64>);
192-
}
193-
194128
pub trait RtioPipe {
195129
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint>;
196130
fn write(&mut self, buf: &[u8]) -> IoResult<()>;

0 commit comments

Comments
 (0)