How to use v2 initializers
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
- Issue type
- Documentation
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- cpp
- Domain
- documentation
Research direction
Start with the Boost.Process v2 process initializer API, especially the CustomInit hook methods and the async_execute entry point shown in the example. Determine whether the hooks are expected to run in this usage, then document the correct initializer pattern and a working example; no specific file or test is named in the issue.
Written by the indexing model from the issue text.
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.
- Dominant language
- C++
- Stars
- 145
- Forks
- 151
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/process
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
All issues in boostorg/process
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
AXERA-TECH/ax-llm#77 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
games-on-whales/wolf#509 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
bug-unconfirmed
Difficulty 2/5 1-3 hours Newbie friendliness 76/100