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 typically work best 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 piping stdin, stdout and stderr, which can be used in simple cases instead of unnamed pipes. Making use of that feature is advisable if the program of the child process can be modified to communicate with its parent via standard I/O streams.

§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.