Open
Description
Hello,
I am excited to use process v2 in my projects. Unfortunately I am having a bit of a hard time understanding the API. If this is not the correct place to post such questions I apologize.
Please see my following example. I cannot get the on_*
functions to run. I am sure I am doing something wrong:
namespace asio = boost::asio;
namespace bp = boost::process::v2;
using namespace std::chrono_literals;
struct CustomInit
{
template <typename Launcher>
std::error_code on_setup(Launcher&, const std::filesystem::path&, const char * const *&)
{
std::cout << "on_setup" << std::endl;
return {};
}
template <typename Launcher>
std::error_code on_error(Launcher&, const std::filesystem::path&, const char * const *&)
{
std::cout << "on_error" << std::endl;
return {};
}
template <typename Launcher>
std::error_code on_success(Launcher&, const std::filesystem::path&, const char * const *&)
{
std::cout << "on_success" << std::endl;
return {};
}
template <typename Launcher>
std::error_code on_fork_error(Launcher&, const std::filesystem::path&, const char * const *&)
{
std::cout << "on_fork_error" << std::endl;
return {};
}
template <typename Launcher>
std::error_code on_exec_setup(Launcher&, const std::filesystem::path&, const char * const *&)
{
std::cout << "on_exec_setup" << std::endl;
return {};
}
template <typename Launcher>
std::error_code on_exec_error(Launcher&, const std::filesystem::path&, const char * const *&)
{
std::cout << "on_exec_error" << std::endl;
return {};
}
};
int
main(void)
{
asio::io_context io;
try {
auto p = bp::process(io, "/usr/bin/sleep", {"1"}, CustomInit{});
bp::async_execute(std::move(p),
[] (const boost::system::error_code &, const int exitCode) {
std::cout << exitCode << std::endl;
});
io.run();
}
catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
}
return 0;
}
Thanks in advance for any assistance you can provide.
Metadata
Metadata
Assignees
Labels
No labels