== `popen.hpp` [#popen] `popen` is a class that launches a process and connect stdin & stdout to pipes. [source,cpp] ---- popen proc(executor, find_executable("addr2line"), {argv[0]}); asio::write(proc, asio::buffer("main\n")); std::string line; asio::read_until(proc, asio::dynamic_buffer(line), '\n'); ---- [source,cpp] ---- // A subprocess with automatically assigned pipes. template struct basic_popen : basic_process { // The executor of the process using executor_type = Executor; // Rebinds the popen type to another executor. template struct rebind_executor { // The pipe type when rebound to the specified executor. typedef basic_popen other; }; // Move construct a popen basic_popen(basic_popen &&) = default; // Move assign a popen basic_popen& operator=(basic_popen &&) = default; // Move construct a popen and change the executor type. template basic_popen(basic_popen&& lhs) : basic_process(std::move(lhs)), stdin_(std::move(lhs.stdin_)), stdout_(std::move(lhs.stdout_)) { } // Create a closed process handle explicit basic_popen(executor_type exec); // Create a closed process handle template explicit basic_popen(ExecutionContext & context); // Construct a child from a property list and launch it using the default process launcher. template explicit basic_popen( executor_type executor, const filesystem::path& exe, std::initializer_list args, Inits&&... inits); // Construct a child from a property list and launch it using the default process launcher. template explicit basic_popen( Launcher && launcher, executor_type executor, const filesystem::path& exe, std::initializer_list args, Inits&&... inits); // Construct a child from a property list and launch it using the default process launcher. template explicit basic_popen( executor_type executor, const filesystem::path& exe, Args&& args, Inits&&... inits); // Construct a child from a property list and launch it using the default process launcher. template explicit basic_popen( Launcher && launcher, executor_type executor, const filesystem::path& exe, Args&& args, Inits&&... inits); // Construct a child from a property list and launch it using the default process launcher. template explicit basic_popen( ExecutionContext & context, const filesystem::path& exe, std::initializer_list args, Inits&&... inits); // Construct a child from a property list and launch it using the default process launcher. template explicit basic_popen( Launcher && launcher, ExecutionContext & context, const filesystem::path& exe, std::initializer_list args, Inits&&... inits); // Construct a child from a property list and launch it using the default process launcher. template explicit basic_popen( ExecutionContext & context, const filesystem::path& exe, Args&& args, Inits&&... inits); // Construct a child from a property list and launch it using the default process launcher. template explicit basic_popen( Launcher && launcher, ExecutionContext & context, const filesystem::path& exe, Args&& args, Inits&&... inits); // The type used for stdin on the parent process side. using stdin_type = net::basic_writable_pipe; // The type used for stdout on the parent process side. using stdout_type = net::basic_readable_pipe; // Get the stdin pipe. // Get the stdout pipe. // Get the stdin pipe. stdin_type & get_stdin(); const stdin_type & get_stdin() const; // Get the stdout pipe. stdout_type & get_stdout(); const stdout_type & get_stdout() const; // Write some data to the stdin pipe. template std::size_t write_some(const ConstBufferSequence& buffers); template std::size_t write_some(const ConstBufferSequence& buffers, boost::system::error_code& ec); // Start an asynchronous write. template > auto async_write_some(const ConstBufferSequence& buffers, WriteToken && token = net::default_completion_token_t()); // Read some data from the stdout pipe. template std::size_t read_some(const MutableBufferSequence& buffers); template std::size_t read_some(const MutableBufferSequence& buffers, boost::system::error_code& ec) // Start an asynchronous read. template > auto async_read_some(const MutableBufferSequence& buffers, BOOST_ASIO_MOVE_ARG(ReadToken) token = net::default_completion_token_t()); }; // A popen object with the default executor. using popen = basic_popen<>; ----