pub struct Pipe { /* private fields */ }
Expand description
Abstraction over UNIX pipe for the specific case here with stdin/stdout redirection between processes. The typical flow is that a Pipe is created, the program is forked and that one process marks it’s part of the Pipe as READ while the other process marks it’s part of the Pipe as WRITE.
Each Pipe object will exists per address space, because we create a child process for each command to be executed.
Each pipe connects two processes. Each process has access to “pipe_to_current” and “pipe_to_next”. First one is used as READ-end while the latter one is used as WRITE-end.
Implementations§
Source§impl Pipe
impl Pipe
pub fn new() -> Self
Sourcepub fn as_read_end(&mut self)
pub fn as_read_end(&mut self)
Marks and locks the Pipe in the current address space as read end.
Sourcepub fn as_write_end(&mut self)
pub fn as_write_end(&mut self)
Marks and locks the Pipe in the current address space as write end.
Sourcepub fn parent_close_all(&mut self)
pub fn parent_close_all(&mut self)
A parent doesn’t uses the pipes. It just creates the objects and make sure they are transferred into the childs (via fork(). After a child process started and got it’s Pipe objects, the parent MUST close it’s FDs in order to prevent deadlocks.