2
0
mirror of https://github.com/boostorg/process.git synced 2026-01-19 04:22:15 +00:00

added BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK

See #430
This commit is contained in:
Klemens Morgenstern
2024-12-13 12:26:46 +08:00
parent 3fe2033062
commit 0f9dd52f02
4 changed files with 32 additions and 5 deletions

View File

@@ -383,11 +383,15 @@ struct default_launcher
auto & ctx = net::query(
exec, net::execution::context);
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_prepare);
#endif
pid = ::fork();
if (pid == -1)
{
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_parent);
#endif
detail::on_fork_error(*this, executable, argv, ec, inits...);
detail::on_error(*this, executable, argv, ec, inits...);
@@ -397,7 +401,9 @@ struct default_launcher
else if (pid == 0)
{
::close(pg.p[0]);
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_child);
#endif
ec = detail::on_exec_setup(*this, executable, argv, inits...);
if (!ec)
{
@@ -412,8 +418,9 @@ struct default_launcher
::exit(EXIT_FAILURE);
return basic_process<Executor>{exec};
}
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_parent);
#endif
::close(pg.p[1]);
pg.p[1] = -1;
int child_error{0};

View File

@@ -86,11 +86,16 @@ struct fork_and_forget_launcher : default_launcher
auto & ctx = net::query(
exec, net::execution::context);
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_prepare);
#endif
pid = ::fork();
if (pid == -1)
{
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_parent);
#endif
detail::on_fork_error(*this, executable, argv, ec, inits...);
detail::on_fork_error(*this, executable, argv, ec, inits...);
detail::on_error(*this, executable, argv, ec, inits...);
@@ -99,8 +104,9 @@ struct fork_and_forget_launcher : default_launcher
}
else if (pid == 0)
{
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_child);
#endif
ec = detail::on_exec_setup(*this, executable, argv, inits...);
if (!ec)
close_all_fds(ec);
@@ -112,7 +118,9 @@ struct fork_and_forget_launcher : default_launcher
::exit(EXIT_FAILURE);
return basic_process<Executor>{exec};
}
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_parent);
#endif
if (ec)
{
detail::on_error(*this, executable, argv, ec, inits...);

View File

@@ -103,11 +103,15 @@ struct pdfork_launcher : default_launcher
auto & ctx = net::query(
exec, net::execution::context);
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_prepare);
#endif
pid = ::pdfork(&fd, PD_DAEMON | PD_CLOEXEC);
if (pid == -1)
{
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_parent);
#endif
detail::on_fork_error(*this, executable, argv, ec, inits...);
detail::on_error(*this, executable, argv, ec, inits...);
@@ -116,7 +120,9 @@ struct pdfork_launcher : default_launcher
}
else if (pid == 0)
{
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_child);
#endif
::close(pg.p[0]);
ec = detail::on_exec_setup(*this, executable, argv, inits...);
@@ -133,7 +139,9 @@ struct pdfork_launcher : default_launcher
::exit(EXIT_FAILURE);
return basic_process<Executor>{exec};
}
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_parent);
#endif
::close(pg.p[1]);
pg.p[1] = -1;
int child_error{0};

View File

@@ -86,13 +86,16 @@ struct vfork_launcher : default_launcher
return basic_process<Executor>(exec);
}
auto & ctx = net::query(
exec, net::execution::context);
auto & ctx = net::query(exec, net::execution::context);
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_prepare);
#endif
pid = ::vfork();
if (pid == -1)
{
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_parent);
#endif
detail::on_fork_error(*this, executable, argv, ec, inits...);
detail::on_error(*this, executable, argv, ec, inits...);
@@ -112,8 +115,9 @@ struct vfork_launcher : default_launcher
::_exit(EXIT_FAILURE);
return basic_process<Executor>{exec};
}
#if !defined(BOOST_PROCESS_V2_DISABLE_NOTIFY_FORK)
ctx.notify_fork(net::execution_context::fork_parent);
#endif
if (ec)
{
detail::on_error(*this, executable, argv, ec, inits...);