[][src]Function nix::unistd::mkfifo

pub fn mkfifo<P: ?Sized + NixPath>(path: &P, mode: Mode) -> Result<()>

Creates new fifo special file (named pipe) with path path and access rights mode.

Errors

There are several situations where mkfifo might fail:

For a full list consult posix specification

Example

extern crate tempfile;
extern crate nix;

use nix::unistd;
use nix::sys::stat;
use tempfile::tempdir;

fn main() {
    let tmp_dir = tempdir().unwrap();
    let fifo_path = tmp_dir.path().join("foo.pipe");

    // create new fifo and give read, write and execute rights to the owner
    match unistd::mkfifo(&fifo_path, stat::Mode::S_IRWXU) {
       Ok(_) => println!("created {:?}", fifo_path),
       Err(err) => println!("Error creating fifo: {}", err),
    }
}