Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:14

0001 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
0002 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
0003 // Copyright (c) 2009 Boris Schaeling
0004 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
0005 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
0006 // Copyright (c) 2016 Klemens D. Morgenstern
0007 //
0008 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0009 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 /**
0012  * \file boost/process/spawn.hpp
0013  *
0014  * Defines the spawn function.
0015  */
0016 
0017 #ifndef BOOST_PROCESS_SPAWN_HPP
0018 #define BOOST_PROCESS_SPAWN_HPP
0019 
0020 #include <boost/process/detail/config.hpp>
0021 #include <boost/process/detail/child_decl.hpp>
0022 #include <boost/process/detail/execute_impl.hpp>
0023 #include <boost/process/detail/async_handler.hpp>
0024 
0025 #if defined(BOOST_POSIX_API)
0026 #include <boost/process/posix.hpp>
0027 #endif
0028 
0029 namespace boost {
0030 
0031 namespace process {
0032 
0033 namespace detail {
0034 
0035 }
0036 
0037 /** Launch a process and detach it. Returns no handle.
0038 
0039 This function starts a process and immediately detaches it. It thereby prevents the system from creating a zombie process,
0040 but will also cause the system to be unable to wait for the child to exit.
0041 
0042 \note This will set `SIGCHLD` to `SIGIGN` on posix.
0043 
0044 \warning This function does not allow asynchronous operations, since it cannot wait for the end of the process.
0045 It will fail to compile if a reference to `boost::asio::io_context` is passed.
0046 
0047  */
0048 template<typename ...Args>
0049 inline void spawn(Args && ...args)
0050 {
0051     typedef typename ::boost::process::detail::has_async_handler<Args...>::type
0052             has_async;
0053 
0054 
0055     static_assert(
0056             !has_async::value,
0057             "Spawn cannot wait for exit, so async properties cannot be used");
0058 
0059     auto c = ::boost::process::detail::execute_impl(
0060 #if defined(BOOST_POSIX_API)
0061             ::boost::process::posix::sig.ign(),
0062 #endif
0063              std::forward<Args>(args)...);
0064     c.detach();
0065 }
0066 
0067 }}
0068 #endif
0069