// https://www.boost.org/doc/libs/1_92_0/doc/html/process.html

#include <boost/asio/io_context.hpp>
#include <boost/process.hpp>

#include <cassert>
#include <iostream>

namespace bp = boost::process::v2;

int main()
{
    boost::asio::io_context ctx;

    const boost::filesystem::path exe = bp::environment::find_executable("true");
    std::cout << "found: " << exe << std::endl;
    assert(!exe.empty());

    // A successful child must report exit code 0
    bp::process ok(ctx, exe, {});
    const int rc_ok = ok.wait();
    std::cout << "true  -> " << rc_ok << std::endl;
    assert(rc_ok == 0);

    // A failing child must report a non-zero exit code
    bp::process ko(ctx, bp::environment::find_executable("false"), {});
    const int rc_ko = ko.wait();
    std::cout << "false -> " << rc_ko << std::endl;
    assert(rc_ko != 0);

    return 0;
}
