child.hpp
Go to the documentation of this file.
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#pragma once
11
12#include <boost/move/move.hpp>
13
14#include <Windows.h>
15
17{
18
19 class child
20 {
21 public:
22 PROCESS_INFORMATION proc_info;
23
24 explicit child(const PROCESS_INFORMATION& pi) : proc_info(pi)
25 {
26 }
27
29 {
30 ::CloseHandle(proc_info.hProcess);
31 ::CloseHandle(proc_info.hThread);
32 }
33
34 child(BOOST_RV_REF(child) c) : proc_info(c.proc_info)
35 {
36 c.proc_info.hProcess = INVALID_HANDLE_VALUE;
37 c.proc_info.hThread = INVALID_HANDLE_VALUE;
38 }
39
40 child&
41 operator=(BOOST_RV_REF(child) c)
42 {
43 ::CloseHandle(proc_info.hProcess);
44 ::CloseHandle(proc_info.hThread);
45 proc_info = c.proc_info;
46 c.proc_info.hProcess = INVALID_HANDLE_VALUE;
47 c.proc_info.hThread = INVALID_HANDLE_VALUE;
48 return *this;
49 }
50
51 HANDLE
53 {
54 return proc_info.hProcess;
55 }
56
57 private:
58 BOOST_MOVABLE_BUT_NOT_COPYABLE(child);
59 };
60
61} // namespace boost::process::windows
#define pi
constexpr T c
child & operator=(BOOST_RV_REF(child) c)
Definition child.hpp:41
child(BOOST_RV_REF(child) c)
Definition child.hpp:34
child(const PROCESS_INFORMATION &pi)
Definition child.hpp:24
HANDLE process_handle() const
Definition child.hpp:52
PROCESS_INFORMATION proc_info
Definition child.hpp:22