How to use v2 initializers
- Dominant language
- C++
- Stars
- 145
- Forks
- 151
- PR merge metrics
- No merged PRs in 30d
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
std::error_code on_setup(Launcher&, const std::filesystem::path&, const char * const *&)
{
std::cout << "on_setup" << std::endl;
return {};
}
template
std::error_code on_error(Launcher&, const std::filesystem::path&, const char * const *&)
{
std::cout << "on_error" << std::endl;
return {};
}
template
std::error_code on_success(Launcher&, const std::filesystem::path&, const char * const *&)
{
std::cout << "on_success" << std::endl;
return {};
}
template
std::error_code on_fork_error(Launcher&, const std::filesystem::path&, const char * const *&)
{
std::cout << "on_fork_error" << std::endl;
return {};
}
template
std::error_code on_exec_setup(Launcher&, const std::filesystem::path&, const char * const *&)
{
std::cout << "on_exec_setup" << std::endl;
return {};
}
template
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.