W3cubDocs

/Rust

Function mkfifo

pub fn mkfifo<P: AsRef<Path>>(path: P, permissions: Permissions) -> Result<()>
🔬This is a nightly-only experimental API. (unix_mkfifo #139324)
Available on Unix only.

Create a FIFO special file at the specified path with the specified mode.

Examples

mkfifo("/tmp/fifo", Permissions::from_mode(0o774))?;

let mut wx = File::options().read(true).write(true).open("/tmp/fifo")?;
let mut rx = File::open("/tmp/fifo")?;

wx.write_all(b"hello, world!")?;
drop(wx);

let mut s = String::new();
rx.read_to_string(&mut s)?;

assert_eq!(s, "hello, world!");

© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/os/unix/fs/fn.mkfifo.html