-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bp::extend::handler in V2? #454
Comments
Similar code, just without the base-class: struct ExecHandler
{
error_code on_exec_setup(posix::default_launcher & /*launcher*/, const filesystem::path & /* exe*/, const char * const * /* argv*/)
{
(void)prctl(PR_SET_PDEATHSIG, SIGTERM);
}
};
process::v2::process p{..., ExecHandler{}}; |
@klemens-morgenstern, thanks a lot! If you don't mind, I have a similar question regarding Windows. I used to achieve the same effect of killing a process when its parent dies with bp::group g;
bp::child p(
...
g,
io_service
);
#ifdef _WIN32
namespace bpd = bp::detail;
bpd::api::workaround::JOBOBJECT_EXTENDED_LIMIT_INFORMATION_ info;
auto h = g.native_handle();
if (!bpd::api::workaround::query_information_job_object(
h,
bpd::api::workaround::JobObjectExtendedLimitInformation_,
static_cast<void*>(&info),
sizeof(info),
nullptr)) {
bpd::throw_last_error("QueryInformationJobObject() failed");
}
info.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
if (!bpd::api::workaround::set_information_job_object(
h,
bpd::api::workaround::JobObjectExtendedLimitInformation_,
static_cast<void*>(&info),
sizeof(info))) {
bpd::throw_last_error("SetInformationJobObject() failed");
}
#endif How to do this with V2? With |
I did not add the group to v2 because there are too many differences between the windows & linux implementation. And it's simple enough, you just got a bit of boilerplate re HANDLEs and error handling. The whole You would need to use the job object directly: #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 |
For V1 I used the following trick to kill a child Linux process when its parent dies:
Is there anything similar to
bp::extend::handler
in V2?The text was updated successfully, but these errors were encountered: