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
46
47
48
//! Creation of FIFO files.
//!
//! Those are sometimes referred to as named pipes. Note that they are completely unrelated to
//! the Windows concept with the same name. "FIFO files" are filesystem objects that allow for
//! synchronous arrangement of a unidirectional pipe connection between two processes, which is
//! only useful when one is not the ancestor of another and an unnamed pipe thus cannot be simply
//! inherited. This synchronization happens at file opening time and can be described as highly
//! aggressive: both the reader and the writer will block on opening the file until the other side
//! has also opened it.
//!
//! If multiple processes read from a FIFO file concurrently, they will compete for sent data; if
//! mulitple processes write to it concurrently, the data will mix unpredictably (albeit subject
//! to OS-specific thresholds of atomicity). In summary, concurrent use of a FIFO file by more
//! than two processes is almost always erroneous.
//!
//! Due to the above, use of FIFO files should be avoided if possible. You may be looking for
//! [local sockets](crate::local_socket) or [Unix domain sockets](std::os::unix::net) instead.
//!
//! ## 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