Opened 5 years ago

Last modified 5 years ago

#13358 new Bugs

boost::process on_exit fails when using multiple processes

Reported by: david.glesser@… Owned by:
Milestone: To Be Determined Component: process
Version: Boost 1.65.0 Severity: Problem
Keywords: Cc:

Description

int main() {
    boost::asio::io_service ios;
    boost::asio::io_service::work working(ios);

    proc::child c1("/bin/sleep 1", ios, proc::on_exit=[](int exit, const std::error_code& ec_in){std::cout<<"11111"<<std::endl;});
    proc::child c2("/bin/sleep 4", ios, proc::on_exit=[](int exit, const std::error_code& ec_in){std::cout<<"44444"<<std::endl;});
    proc::child c3("/bin/sleep 2", ios, proc::on_exit=[](int exit, const std::error_code& ec_in){std::cout<<"22222"<<std::endl;});
    ios.run();

    return 0;
}

prints

22222
44444
11111

while it should prints 11111, 22222 and then 44444. However, 22222 is printed after 1 second, 44444 after 2s, and 11111 after 4s.

The same error happen if you use:

    boost::process::async_system(ios, [](boost::system::error_code, int){std::cout << "11111" << std::endl;}, "/bin/sleep 1");

This was observed on an up-to-date Archlinux (as of 2017-12-22) with gcc 7.2.1 and clang 5.0.0.

Change History (1)

comment:1 by david.glesser@…, 5 years ago

I just noticed that this issue has already been reported on another issue tracker : https://github.com/klemens-morgenstern/boost-process/issues/109 .

Note: See TracTickets for help on using tickets.