unix-ipc

This crate implements a minimal abstraction over UNIX domain sockets for the purpose of IPC. It lets you send both file handles and rust objects between processes.

Example

```rust use std::env; use std::process; use unix_ipc::{channel, Bootstrapper, Receiver, Sender}; use serde::{Deserialize, Serialize};

const ENVVAR: &str = "PROCCONNECT_TO";

[derive(Serialize, Deserialize, Debug)]

pub enum Task { Sum(Vec, Sender), Shutdown, }

fn main() { if let Ok(path) = env::var(ENVVAR) { let receiver = Receiver::::connect(path).unwrap(); loop { match receiver.recv().unwrap() { Task::Sum(values, tx) => { tx.send(values.intoiter().sum::()).unwrap(); } Task::Shutdown => break, } } } else { let bootstrapper = Bootstrapper::new().unwrap(); let mut child = process::Command::new(env::currentexe().unwrap()) .env(ENVVAR, bootstrapper.path()) .spawn() .unwrap();

    let (tx, rx) = channel().unwrap();
    bootstrapper.send(Task::Sum(vec![23, 42], tx)).unwrap();
    println!("sum: {}", rx.recv().unwrap());
    bootstrapper.send(Task::Shutdown).unwrap();
}

} ```

Feature Flags

All features are enabled by default but a lot can be turned off to cut down on dependencies. With all default features enabled only the raw types are available.