Module interprocess::unnamed_pipe
source · Expand description
Creation and usage of unnamed pipes.
The primary distinction between named and unnamed pipes is rather trivial: named pipes have names in their special named pipe filesystem, while unnamed pipes only have handles. This can both be useful or problematic, depending on the use case. Unnamed pipes 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. 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.
Structs§
- Handle to the receiving end of an unnamed pipe, created by the
pipe()
function together with the sending end. - Handle to the sending end of an unnamed pipe, created by the
pipe()
function together with the receiving end.
Functions§
- Creates a new pipe with the default creation settings and returns the handles to its sending end and receiving end.