1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
//{
use std::{io, os};
#[cfg(windows)]
type Handle = os::windows::io::OwnedHandle;
#[cfg(unix)]
type Handle = os::unix::io::OwnedFd;
pub(crate) fn emain(handle: Handle) -> io::Result<()> {
//}
use {interprocess::unnamed_pipe, std::io::prelude::*};
// `handle` here is an `OwnedHandle` or an `OwnedFd` from the standard library. Those
// implement `FromRawHandle` and `FromRawFd` respectively. The actual value can be transferred
// via a command-line parameter since it's numerically equal to the value obtained in the
// parent process via `OwnedHandle::from()`/`OwnedFd::from()` thanks to handle inheritance.
let mut tx = unnamed_pipe::Sender::from(handle);
// Send our message to the other side.
tx.write_all(b"Hello from side B!\n")?;
//{
Ok(())
}
#[allow(dead_code)]
fn main() {} //}
|