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 // 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 10 #ifndef BOOST_PROCESS_POSIX_CHILD_HPP 11 #define BOOST_PROCESS_POSIX_CHILD_HPP 12 13 #include <utility> 14 #include <system_error> 15 16 namespace boost { namespace process { namespace detail { namespace posix { 17 18 typedef ::pid_t pid_t; 19 20 struct child_handle 21 { 22 int pid {-1}; child_handleboost::process::detail::posix::child_handle23 explicit child_handle(int pid) : pid(pid) 24 {} 25 26 child_handle() = default; 27 ~child_handle() = default; 28 29 child_handle(const child_handle & c) = delete; child_handleboost::process::detail::posix::child_handle30 child_handle(child_handle && c) : pid(c.pid) 31 { 32 c.pid = -1; 33 } 34 child_handle &operator=(const child_handle & c) = delete; operator =boost::process::detail::posix::child_handle35 child_handle &operator=(child_handle && c) 36 { 37 pid = c.pid; 38 c.pid = -1; 39 return *this; 40 } 41 idboost::process::detail::posix::child_handle42 int id() const 43 { 44 return pid; 45 } in_groupboost::process::detail::posix::child_handle46 bool in_group() const {return true;} in_groupboost::process::detail::posix::child_handle47 bool in_group(std::error_code&) const noexcept {return true;} 48 49 typedef int process_handle_t; process_handleboost::process::detail::posix::child_handle50 process_handle_t process_handle() const { return pid; } 51 validboost::process::detail::posix::child_handle52 bool valid() const 53 { 54 return pid != -1; 55 } 56 }; 57 58 }}}} 59 60 #endif 61