JeffGarland / liaw2019-process

Repository for initial drafting of boost.process standards paper
MIT License
5 stars 4 forks source link

Terminate in destructor #56

Open klemens-morgenstern opened 4 years ago

klemens-morgenstern commented 4 years ago

As a trivial example, why we must terminate in the constructor, the following code causes a deadlock if we wait in the destructor.

std::opstream pin:
std::ipstream pout;

std::process proc{"python", std::process_io(pin, pout)};
throw 42;

The python process will wait for the pipe to close (or the exit command), but the pipe will be closed after the process is destruced.