Skip to content

Instantly share code, notes, and snippets.

@mkmik
Created March 10, 2021 03:32
Show Gist options
  • Select an option

  • Save mkmik/54cad656106fe510a19f610b2aab8286 to your computer and use it in GitHub Desktop.

Select an option

Save mkmik/54cad656106fe510a19f610b2aab8286 to your computer and use it in GitHub Desktop.
use std::process::{Command, Stdio};
use std::os::unix::net::UnixStream;
use std::os::unix::io::{AsRawFd,FromRawFd};
fn main() {
let (_sock1, sock2) = UnixStream::pair().unwrap();
Command::new("sleep")
.arg("200")
.stdin(unsafe{Stdio::from_raw_fd(sock2.as_raw_fd())})
.spawn()
.expect("ls command failed to start");
println!("Hello, world!");
//std::thread::sleep(std::time::Duration::from_secs(4));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment