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

Remove rtio #18557

Merged
merged 11 commits into from
Nov 9, 2014
Prev Previous commit
Next Next commit
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.
  • Loading branch information
aturon committed Nov 9, 2014
commit 0f98e75b69d16edce9ca60d7961b8440856a3f72
20 changes: 0 additions & 20 deletions src/libnative/io/mod.rs
Original file line number Diff line number Diff line change
@@ -29,13 +29,6 @@ use std::os;
use std::rt::rtio::{mod, IoResult, IoError};
use std::num;

// Local re-exports
pub use self::process::Process;

// Native I/O implementations
pub mod process;
mod util;

#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
@@ -123,19 +116,6 @@ impl rtio::IoFactory for IoFactory {
fn timer_init(&mut self) -> IoResult<Box<rtio::RtioTimer + Send>> {
timer::Timer::new().map(|t| box t as Box<rtio::RtioTimer + Send>)
}
fn spawn(&mut self, cfg: rtio::ProcessConfig)
-> IoResult<(Box<rtio::RtioProcess + Send>,
Vec<Option<Box<rtio::RtioPipe + Send>>>)> {
process::Process::spawn(cfg).map(|(p, io)| {
(box p as Box<rtio::RtioProcess + Send>,
io.into_iter().map(|p| p.map(|p| {
box p as Box<rtio::RtioPipe + Send>
})).collect())
})
}
fn kill(&mut self, pid: libc::pid_t, signum: int) -> IoResult<()> {
process::Process::kill(pid, signum)
}
#[cfg(unix)]
fn tty_open(&mut self, fd: c_int, _readable: bool)
-> IoResult<Box<rtio::RtioTTY + Send>> {
66 changes: 0 additions & 66 deletions src/librustrt/rtio.rs
Original file line number Diff line number Diff line change
@@ -46,61 +46,6 @@ pub trait RemoteCallback {
fn fire(&mut self);
}

/// Data needed to spawn a process. Serializes the `std::io::process::Command`
/// builder.
pub struct ProcessConfig<'a> {
/// Path to the program to run.
pub program: &'a CString,

/// Arguments to pass to the program (doesn't include the program itself).
pub args: &'a [CString],

/// Optional environment to specify for the program. If this is None, then
/// it will inherit the current process's environment.
pub env: Option<&'a [(&'a CString, &'a CString)]>,

/// Optional working directory for the new process. If this is None, then
/// the current directory of the running process is inherited.
pub cwd: Option<&'a CString>,

/// Configuration for the child process's stdin handle (file descriptor 0).
/// This field defaults to `CreatePipe(true, false)` so the input can be
/// written to.
pub stdin: StdioContainer,

/// Configuration for the child process's stdout handle (file descriptor 1).
/// This field defaults to `CreatePipe(false, true)` so the output can be
/// collected.
pub stdout: StdioContainer,

/// Configuration for the child process's stdout handle (file descriptor 2).
/// This field defaults to `CreatePipe(false, true)` so the output can be
/// collected.
pub stderr: StdioContainer,

/// Any number of streams/file descriptors/pipes may be attached to this
/// process. This list enumerates the file descriptors and such for the
/// process to be spawned, and the file descriptors inherited will start at
/// 3 and go to the length of this array. The first three file descriptors
/// (stdin/stdout/stderr) are configured with the `stdin`, `stdout`, and
/// `stderr` fields.
pub extra_io: &'a [StdioContainer],

/// Sets the child process's user id. This translates to a `setuid` call in
/// the child process. Setting this value on windows will cause the spawn to
/// fail. Failure in the `setuid` call on unix will also cause the spawn to
/// fail.
pub uid: Option<uint>,

/// Similar to `uid`, but sets the group id of the child process. This has
/// the same semantics as the `uid` field.
pub gid: Option<uint>,

/// If true, the child process is spawned in a detached state. On unix, this
/// means that the child is the leader of a new process group.
pub detach: bool,
}

pub struct LocalIo<'a> {
factory: &'a mut IoFactory+'a,
}
@@ -170,10 +115,6 @@ impl<'a> LocalIo<'a> {

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

pub trait RtioProcess {
fn id(&self) -> libc::pid_t;
fn kill(&mut self, signal: int) -> IoResult<()>;
fn wait(&mut self) -> IoResult<ProcessExit>;
fn set_timeout(&mut self, timeout: Option<u64>);
}

pub trait RtioPipe {
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint>;
fn write(&mut self, buf: &[u8]) -> IoResult<()>;
Loading