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

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

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

Errors

There are several situations where mkfifo might fail:

  • current user has insufficient rights in the parent directory
  • the path already exists
  • the path name is too long (longer than PATH_MAX, usually 4096 on linux, 1024 on OS X)

For a full list consult posix specification

Example

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

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),
}