@klemens-morgenstern, we already discussed this in #454, but you probably missed my last comment left after the issue was closed. I can't reopen it, so I have opened this new issue to continue the conversation.
Your solution
#include <windows.h>
#include <boost/process/windows/creation_flag.hpp>
auto h = ::CreateJobObjectW(nullptr, nullptr); // don't forget the CloseHandle
bp::process proc(..., boost::process::windows::create_breakaway_from_job);
AssignProcessToJobObject(h, proc.native_handle()); // error handling...
// now do with the job object `h` what you have above
seems to have a flaw. If the child process manages to create a grandchild process before AssignProcessToJobObject is called, the grandchild won't be killed be the OS on the main process crash. V1 allowed to include the child process into the main process' group before it runs; for v2 it's not possible. Another option is to create the child process suspended, as recommended here: https://devblogs.microsoft.com/oldnewthing/20131209-00/?p=2433, but to resume it one have to know the main thread handle, that cannot be fetched from bp::process object. So currently there is no solution that works with v2.
@klemens-morgenstern, we already discussed this in #454, but you probably missed my last comment left after the issue was closed. I can't reopen it, so I have opened this new issue to continue the conversation.
Your solution
seems to have a flaw. If the child process manages to create a grandchild process before AssignProcessToJobObject is called, the grandchild won't be killed be the OS on the main process crash. V1 allowed to include the child process into the main process' group before it runs; for v2 it's not possible. Another option is to create the child process suspended, as recommended here: https://devblogs.microsoft.com/oldnewthing/20131209-00/?p=2433, but to resume it one have to know the main thread handle, that cannot be fetched from bp::process object. So currently there is no solution that works with v2.