child_handle.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #ifndef BOOST_PROCESS_POSIX_CHILD_HPP
  10. #define BOOST_PROCESS_POSIX_CHILD_HPP
  11. #include <utility>
  12. #include <system_error>
  13. namespace boost { namespace process { namespace detail { namespace posix {
  14. typedef ::pid_t pid_t;
  15. struct child_handle
  16. {
  17. int pid {-1};
  18. explicit child_handle(int pid) : pid(pid)
  19. {}
  20. child_handle() = default;
  21. ~child_handle() = default;
  22. child_handle(const child_handle & c) = delete;
  23. child_handle(child_handle && c) : pid(c.pid)
  24. {
  25. c.pid = -1;
  26. }
  27. child_handle &operator=(const child_handle & c) = delete;
  28. child_handle &operator=(child_handle && c)
  29. {
  30. pid = c.pid;
  31. c.pid = -1;
  32. return *this;
  33. }
  34. int id() const
  35. {
  36. return pid;
  37. }
  38. bool in_group() const {return true;}
  39. bool in_group(std::error_code&) const noexcept {return true;}
  40. typedef int process_handle_t;
  41. process_handle_t process_handle() const { return pid; }
  42. bool valid() const
  43. {
  44. return pid != -1;
  45. }
  46. };
  47. }}}}
  48. #endif