![]() |
Home | Libraries | People | FAQ | More |
boost::process::std_in
// In header: <boost/process/io.hpp> std_in;
This property allows to set the input stream for the child process.
The file I/O simple redirects the stream to a file, for which the possible types are
boost::process::filesystem::path
std::basic_string<char_type>
const char_type*
FILE*
with char_type
being either char
or wchar_t
.
FILE* is explicitly added, so the process can easily redirect the output stream of the child to another output stream of the process. That is:
![]() |
Warning |
---|---|
If the launching and the child process use the input, this leads to undefined behaviour. |
A syntax like system("ls", std_out > std::cerr)
is not possible, due to the C++ implementation not providing access to the handle.
The valid expressions for this property are
As explained in the corresponding section, the boost.process library provides a async_pipe class which can be used to communicate with child processes.
![]() |
Note |
---|---|
Technically the async_pipe works synchronous here, since no asio implementation is used by the library here. The async-operation will then however not end if the process is finished, since the pipe remains open. You can use the async_close function with on_exit to fix that. |
Valid expressions with pipes are these:
pipe; pipe;
Where the valid types for pipe
are the following:
Note that the pipe may also be used between several processes, like this:
pipe child child
Asynchronous Pipe I/O classifies communication which has automatically handling of the asynchronous operations by the process library. This means, that a pipe will be constructed, the async_read/-write will be automatically started, and that the end of the child process will also close the pipe.
Valid types for pipe I/O are the following:
Valid expressions with pipes are these:
![]() |
Note |
---|---|
It is also possible to get a future for std_in, by chaining another child |
![]() |
Note |
---|---|
|
![]() |
Warning |
---|---|
This feature requires |
The input stream can be closed, so it cannot be read from. This will lead to an error when attempted.
This can be achieved by the following syntax.