2
0
mirror of https://github.com/boostorg/process.git synced 2026-01-19 04:22:15 +00:00
Files
process/doc/reference/stdio.adoc
Klemens Morgenstern bd450f9831 fixed wrong comment/doc using .stderr
Closes #500
2025-06-26 23:17:08 +08:00

55 lines
1.5 KiB
Plaintext

== `stdio.hpp`
[#stdio]
The initializer for the stdio of a subprocess
The subprocess stdio initializer has three members:
- in for stdin
- out for stdout
- err for stderr
If the initializer is present all three will be set for the subprocess.
By default they will inherit the stdio handles from the parent process.
This means that this will forward stdio to the subprocess:
[source,cpp]
----
asio::io_context ctx;
v2::process proc(ctx, "/bin/bash", {}, v2::process_stdio{});
----
No constructors are provided in order to support designated initializers
in later version of C++.
[source,cpp]
----
asio::io_context ctx;
/// C++17
v2::process proc17(ctx, "/bin/bash", {}, v2::process_stdio{.err=nullptr});
/// C++11 & C++14
v2::process proc17(ctx, "/bin/bash", {}, v2::process_stdio{ {}, {}, nullptr});
----
Valid initializers for any stdio are:
- `std::nullptr_t` assigning a null-device
- `FILE*` any open file, including `stdin`, `stdout` and `stderr`
- a filesystem::path, which will open a readable or writable depending on the direction of the stream
- `native_handle` any native file handle (`HANDLE` on windows) or file descriptor (`int` on posix)
- any io-object with a .native_handle() function that is compatible with the above. E.g. a asio::ip::tcp::socket
- an asio::basic_writeable_pipe for stdin or asio::basic_readable_pipe for stderr/stdout.
[source,cpp]
----
/// The initializer for the stdio of a subprocess
struct process_stdio
{
__implementation_defined__ in;
__implementation_defined__ out;
__implementation_defined__ err;
};
----