1 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
2 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
3 // Copyright (c) 2009 Boris Schaeling
4 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
5 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
6 // Copyright (c) 2016 Klemens D. Morgenstern
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12 * \file boost/process/spawn.hpp
14 * Defines the spawn function.
17 #ifndef BOOST_PROCESS_SPAWN_HPP
18 #define BOOST_PROCESS_SPAWN_HPP
20 #include <boost/process/detail/config.hpp>
21 #include <boost/process/detail/child_decl.hpp>
22 #include <boost/process/detail/execute_impl.hpp>
23 #include <boost/process/detail/async_handler.hpp>
25 #if defined(BOOST_POSIX_API)
26 #include <boost/process/posix.hpp>
37 /** Launch a process and detach it. Returns no handle.
39 This function starts a process and immediately detaches it. It thereby prevents the system from creating a zombie process,
40 but will also cause the system to be unable to wait for the child to exit.
42 \note This will set `SIGCHLD` to `SIGIGN` on posix.
44 \warning This function does not allow asynchronous operations, since it cannot wait for the end of the process.
45 It will fail to compile if a reference to `boost::asio::io_context` is passed.
48 template<typename ...Args>
49 inline void spawn(Args && ...args)
51 typedef typename ::boost::process::detail::has_async_handler<Args...>::type
57 "Spawn cannot wait for exit, so async properties cannot be used");
59 auto c = ::boost::process::detail::execute_impl(
60 #if defined(BOOST_POSIX_API)
61 ::boost::process::posix::sig.ign(),
63 std::forward<Args>(args)...);