Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c2e9dbc

Browse files
authoredJan 26, 2025··
Unrolled build for rust-lang#134373
Rollup merge of rust-lang#134373 - joshtriplett:pipe-docs, r=joboet Improve and expand documentation of pipes - Reference UNIX, not just Linux - Simplify some of the language - Don't imply that pipes *only* work across multiple processes; instead, *suggest* that they're typically used across two or more separate processes. - Specify that portable applications cannot use multiple readers or multiple writers for messages larger than a byte, due to potential interleaving. Tracking issue for anonymous pipes: rust-lang#127154
2 parents 6fb0358 + 687607c commit c2e9dbc

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed
 

‎library/std/src/io/mod.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -3252,18 +3252,26 @@ impl<B: BufRead> Iterator for Lines<B> {
32523252
}
32533253
}
32543254

3255-
/// Create anonymous pipe that is close-on-exec and blocking.
3255+
/// Create an anonymous pipe that is close-on-exec and blocking.
32563256
///
32573257
/// # Behavior
32583258
///
3259-
/// A pipe is a synchronous, unidirectional data channel between two or more processes, like an
3260-
/// interprocess [`mpsc`](crate::sync::mpsc) provided by the OS. In particular:
3259+
/// A pipe is a one-way data channel provided by the OS, which works across processes. A pipe is
3260+
/// typically used to communicate between two or more separate processes, as there are better,
3261+
/// faster ways to communicate within a single process.
3262+
///
3263+
/// In particular:
32613264
///
32623265
/// * A read on a [`PipeReader`] blocks until the pipe is non-empty.
32633266
/// * A write on a [`PipeWriter`] blocks when the pipe is full.
32643267
/// * When all copies of a [`PipeWriter`] are closed, a read on the corresponding [`PipeReader`]
32653268
/// returns EOF.
3266-
/// * [`PipeReader`] can be shared, but only one process will consume the data in the pipe.
3269+
/// * [`PipeWriter`] can be shared, and multiple processes or threads can write to it at once, but
3270+
/// writes (above a target-specific threshold) may have their data interleaved.
3271+
/// * [`PipeReader`] can be shared, and multiple processes or threads can read it at once. Any
3272+
/// given byte will only get consumed by one reader. There are no guarantees about data
3273+
/// interleaving.
3274+
/// * Portable applications cannot assume any atomicity of messages larger than a single byte.
32673275
///
32683276
/// # Capacity
32693277
///
@@ -3301,21 +3309,19 @@ impl<B: BufRead> Iterator for Lines<B> {
33013309
/// # Ok(())
33023310
/// # }
33033311
/// ```
3304-
/// [pipe]: https://man7.org/linux/man-pages/man2/pipe.2.html
3305-
/// [CreatePipe]: https://learn.microsoft.com/en-us/windows/win32/api/namedpipeapi/nf-namedpipeapi-createpipe
33063312
/// [man page]: https://man7.org/linux/man-pages/man7/pipe.7.html
33073313
#[unstable(feature = "anonymous_pipe", issue = "127154")]
33083314
#[inline]
33093315
pub fn pipe() -> Result<(PipeReader, PipeWriter)> {
33103316
pipe_inner().map(|(reader, writer)| (PipeReader(reader), PipeWriter(writer)))
33113317
}
33123318

3313-
/// Read end of the anonymous pipe.
3319+
/// Read end of an anonymous pipe.
33143320
#[unstable(feature = "anonymous_pipe", issue = "127154")]
33153321
#[derive(Debug)]
33163322
pub struct PipeReader(pub(crate) AnonPipe);
33173323

3318-
/// Write end of the anonymous pipe.
3324+
/// Write end of an anonymous pipe.
33193325
#[unstable(feature = "anonymous_pipe", issue = "127154")]
33203326
#[derive(Debug)]
33213327
pub struct PipeWriter(pub(crate) AnonPipe);

0 commit comments

Comments
 (0)
Please sign in to comment.