1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Creation of FIFO files.
//!
//! On Windows, named pipes can be compared to Unix domain sockets: they can have multiple duplex
//! connections on a single path, and the data can be chosen to either preserve or erase the message
//! boundaries, resulting in a reliable performant alternative to TCP and UDP working in the bounds
//! of a single machine. Those Unix domain sockets are employed by `interprocess` for local sockets
//! via [an implementation provided by the standard library](std::os::unix::net).
//!
//! On Unix, named pipes, referred to as "FIFO files" in this crate, are just files which can have
//! a sender and a receiver communicating with each other in one direction without message
//! boundaries. If further receivers try to open the file, they will simply receive nothing at all;
//! if further senders are connected, the data mixes in an unpredictable way, making it unusable.
//! Therefore, FIFOs are to be used specifically to conveniently connect two applications through a
//! known path which works like a pipe and nothing else.
//!
//! ## Usage
//! The [`create_fifo()`] function serves for a FIFO file creation. Opening FIFO files works via the
//! standard [`File`](std::fs::File)s, opened either only for sending or only for receiving.
//! Deletion works the same way as with any regular file, via
//! [`remove_file()`](std::fs::remove_file).
use ;
/// Creates a FIFO file at the specified path with the specified permissions.
///
/// Since the `mode` parameter is masked with the [`umask`], it's best to leave it at `0o777` unless
/// a different value is desired.
///
/// ## System calls
/// - [`mkfifo`]
///
/// [`mkfifo`]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/mkfifo.html
/// [`umask`]: https://en.wikipedia.org/wiki/Umask