/usr/include/boost/process
NameSizeModeActions
detail/-0755rm
args.hpp89680644editdlrm
async.hpp36830644editdlrm
async_pipe.hpp76940644editdlrm
async_system.hpp45350644editdlrm
child.hpp53090644editdlrm
cmd.hpp30720644editdlrm
env.hpp123010644editdlrm
environment.hpp247580644editdlrm
error.hpp66570644editdlrm
exception.hpp7100644editdlrm
exe.hpp25360644editdlrm
extend.hpp145850644editdlrm
group.hpp67600644editdlrm
handles.hpp30380644editdlrm
io.hpp199900644editdlrm
locale.hpp69680644editdlrm
pipe.hpp187630644editdlrm
posix.hpp28480644editdlrm
search_path.hpp17750644editdlrm
shell.hpp25890644editdlrm
spawn.hpp19290644editdlrm
start_dir.hpp34490644editdlrm
system.hpp40930644editdlrm
windows.hpp36750644editdlrm
Edit: /usr/include/boost/process/system.hpp (4093B)
// Copyright (c) 2006, 2007 Julio M. Merino Vidal // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling // Copyright (c) 2009 Boris Schaeling // Copyright (c) 2010 Felipe Tanus, Boris Schaeling // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling // Copyright (c) 2016 Klemens D. Morgenstern // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) /** * \file boost/process/system.hpp * * Defines a system function. */ #ifndef BOOST_PROCESS_SYSTEM_HPP #define BOOST_PROCESS_SYSTEM_HPP #include #include #include #include #include #include #include #include #include #if defined(BOOST_POSIX_API) #include #endif namespace boost { namespace process { namespace detail { struct system_impl_success_check : handler { bool succeeded = false; template void on_success(Exec &) { succeeded = true; } }; template inline int system_impl( std::true_type, /*needs ios*/ std::true_type, /*has io_context*/ Args && ...args) { IoService & ios = ::boost::process::detail::get_io_context_var(args...); system_impl_success_check check; std::atomic_bool exited{false}; child c(std::forward(args)..., check, ::boost::process::on_exit( [&](int, const std::error_code&) { boost::asio::post(ios.get_executor(), [&]{exited.store(true);}); })); if (!c.valid() || !check.succeeded) return -1; while (!exited.load()) ios.poll(); return c.exit_code(); } template inline int system_impl( std::true_type, /*needs ios */ std::false_type, /*has io_context*/ Args && ...args) { IoService ios; child c(ios, std::forward(args)...); if (!c.valid()) return -1; ios.run(); if (c.running()) c.wait(); return c.exit_code(); } template inline int system_impl( std::false_type, /*needs ios*/ std::true_type, /*has io_context*/ Args && ...args) { child c(std::forward(args)...); if (!c.valid()) return -1; c.wait(); return c.exit_code(); } template inline int system_impl( std::false_type, /*has async */ std::false_type, /*has io_context*/ Args && ...args) { child c(std::forward(args)... #if defined(BOOST_POSIX_API) ,::boost::process::posix::sig.dfl() #endif ); if (!c.valid()) return -1; c.wait(); return c.exit_code(); } } /** Launches a process and waits for its exit. It works as std::system, though it allows all the properties boost.process provides. It will execute the process and wait for it's exit; then return the exit_code. \code{.cpp} int ret = system("ls"); \endcode \attention Using this function with synchronous pipes leads to many potential deadlocks. When using this function with an asynchronous properties and NOT passing an io_context object, the system function will create one and run it. When the io_context is passed to the function, the system function will check if it is active, and call the io_context::run function if not. */ template inline int system(Args && ...args) { typedef typename ::boost::process::detail::needs_io_context::type need_ios; typedef typename ::boost::process::detail::has_io_context::type has_ios; return ::boost::process::detail::system_impl( need_ios(), has_ios(), std::forward(args)...); } }} #endif