diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-09-16 15:28:56 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-09-18 13:52:18 -0700 |
| commit | cb7756a81d3cbc48e79ffaa1a1f9d4934b581166 (patch) | |
| tree | 6e66301c7448c286d8c00a8d402ed8ce132f0fba /src/libstd/rt/rtio.rs | |
| parent | d2b0b11aebfe3167bf41f7c6c31cf7b1e396efe7 (diff) | |
| download | rust-cb7756a81d3cbc48e79ffaa1a1f9d4934b581166.tar.gz rust-cb7756a81d3cbc48e79ffaa1a1f9d4934b581166.zip | |
Implement process bindings to libuv
This is a re-landing of #8645, except that the bindings are *not* being used to power std::run just yet. Instead, this adds the bindings as standalone bindings inside the rt::io::process module. I made one major change from before, having to do with how pipes are created/bound. It's much clearer now when you can read/write to a pipe, as there's an explicit difference (different types) between an unbound and a bound pipe. The process configuration now takes unbound pipes (and consumes ownership of them), and will return corresponding pipe structures back if spawning is successful (otherwise everything is destroyed normally).
Diffstat (limited to 'src/libstd/rt/rtio.rs')
| -rw-r--r-- | src/libstd/rt/rtio.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libstd/rt/rtio.rs b/src/libstd/rt/rtio.rs index d05a3a26169..ca521c792dc 100644 --- a/src/libstd/rt/rtio.rs +++ b/src/libstd/rt/rtio.rs @@ -8,11 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use libc; use option::*; use result::*; use libc::c_int; use rt::io::IoError; +use super::io::process::ProcessConfig; use super::io::net::ip::{IpAddr, SocketAddr}; use rt::uv::uvio; use path::Path; @@ -31,6 +33,9 @@ pub type RtioTcpListenerObject = uvio::UvTcpListener; pub type RtioUdpSocketObject = uvio::UvUdpSocket; pub type RtioTimerObject = uvio::UvTimer; pub type PausibleIdleCallback = uvio::UvPausibleIdleCallback; +pub type RtioPipeObject = uvio::UvPipeStream; +pub type RtioUnboundPipeObject = uvio::UvUnboundPipe; +pub type RtioProcessObject = uvio::UvProcess; pub trait EventLoop { fn run(&mut self); @@ -79,6 +84,9 @@ pub trait IoFactory { fn fs_rmdir<P: PathLike>(&mut self, path: &P) -> Result<(), IoError>; fn fs_readdir<P: PathLike>(&mut self, path: &P, flags: c_int) -> Result<~[Path], IoError>; + fn pipe_init(&mut self, ipc: bool) -> Result<~RtioUnboundPipeObject, IoError>; + fn spawn(&mut self, config: ProcessConfig) + -> Result<(~RtioProcessObject, ~[Option<RtioPipeObject>]), IoError>; } pub trait RtioTcpListener : RtioSocket { @@ -135,3 +143,14 @@ pub trait RtioFileStream { fn tell(&self) -> Result<u64, IoError>; fn flush(&mut self) -> Result<(), IoError>; } + +pub trait RtioProcess { + fn id(&self) -> libc::pid_t; + fn kill(&mut self, signal: int) -> Result<(), IoError>; + fn wait(&mut self) -> int; +} + +pub trait RtioPipe { + fn read(&mut self, buf: &mut [u8]) -> Result<uint, IoError>; + fn write(&mut self, buf: &[u8]) -> Result<(), IoError>; +} |
