]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/process/example/io.cpp
1 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
2 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
3 // Copyright (c) 2009 Boris Schaeling
4 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
5 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 #include <boost/process.hpp>
13 namespace bp
= boost::process
;
20 bp::std_out
> stdout
, //forward
21 bp::std_err
.close(), //close
22 bp::std_in
< bp::null
//null in
25 boost::filesystem::path p
= "input.txt";
29 (bp::std_out
& bp::std_err
) > "output.txt", //redirect both to one file
30 bp::std_in
< p
//read input from file
47 boost::asio::io_context io_context
;
48 bp::async_pipe
p1(io_context
);
49 bp::async_pipe
p2(io_context
);
55 bp::on_exit([&](int exit
, const std::error_code
& ec_in
)
61 std::vector
<char> in_buf
;
62 std::string value
= "my_string";
63 boost::asio::async_write(p1
, boost::asio::buffer(value
), []( const boost::system::error_code
&, std::size_t){});
64 boost::asio::async_read (p2
, boost::asio::buffer(in_buf
), []( const boost::system::error_code
&, std::size_t){});
67 boost::asio::io_context io_context
;
68 std::vector
<char> in_buf
;
69 std::string value
= "my_string";
72 bp::std_out
> bp::buffer(in_buf
),
73 bp::std_in
< bp::buffer(value
)
78 boost::asio::io_context io_context
;
79 std::future
<std::vector
<char>> in_buf
;
80 std::future
<void> write_fut
;
81 std::string value
= "my_string";
85 bp::std_in
< bp::buffer(value
) > write_fut