Skip to main content

Module unnamed_pipe

Module unnamed_pipe 

Source
Expand description

Creation and usage of unnamed pipes.

Unlike named pipes, unnamed pipes are only accessible through their handles – once an endpoint is closed, its corresponding end of the pipe is no longer accessible. Unnamed pipes generally only make sense to use when communicating with child processes.

The handles and file descriptors are inheritable by default. The AsRawHandle and AsRawFd traits can be used to get a numeric handle value which can then be communicated to a child process using a command-line argument, environment variable or some other program startup IPC method. The numeric value can then be reconstructed into an I/O object using FromRawHandle/FromRawFd. Interprocess does not concern itself with how this is done.

Note the standard library’s support for creating unnamed pipes for stdin, stdout and stderr, which should be used in simple cases instead of this module. Making use of std-provided pipe creation is recommended if the program of the child process can be modified to communicate with its parent via standard I/O streams, since unnamed pipes feature comparatively little overhead, have consistent behavior across platforms, and play nicely with command-line utilities.

§Examples

See pipe().

Modules§

tokiotokio
Tokio-based asynchronous unnamed pipes.

Structs§

Recver
Handle to the receiving end of an unnamed pipe, created by the pipe() function together with the sending end.
Sender
Handle to the sending end of an unnamed pipe, created by the pipe() function together with the receiving end.

Functions§

pipe
Creates a new pipe with the default creation settings and returns the handles to its sending end and receiving end.