winss
process.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016-2017 Morgan Stanley
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LIB_WINSS_PROCESS_HPP_
18 #define LIB_WINSS_PROCESS_HPP_
19 
20 #include <windows.h>
21 #include <string>
22 #include "handle_wrapper.hpp"
23 #include "environment.hpp"
24 
25 namespace winss {
29 struct ProcessParams {
30  std::string cmd;
31  bool create_group;
32  std::string dir;
37 };
38 
42 class Process {
43  private:
44  PROCESS_INFORMATION proc_info;
46  public:
50  Process();
51 
53  Process(const Process&) = delete;
54 
60  Process(Process&& p);
61 
67  virtual DWORD GetProcessId() const;
68 
74  virtual DWORD GetExitCode() const;
75 
81  virtual bool IsCreated() const;
82 
88  virtual bool IsActive() const;
89 
96  virtual winss::HandleWrapper GetHandle() const;
97 
104  virtual bool Create(const ProcessParams& params);
105 
111  virtual void SendBreak();
112 
118  virtual void Terminate();
119 
123  virtual void Close();
124 
126  Process& operator=(const Process&) = delete;
127 
133  Process& operator=(Process&& p);
134 
138  ~Process();
139 };
140 } // namespace winss
141 
142 #endif // LIB_WINSS_PROCESS_HPP_
A wrapper for a Windows HANDLE.
Definition: handle_wrapper.hpp:39
std::string dir
Start the process in this directory.
Definition: process.hpp:32
Parameters to start a Windows process.
Definition: process.hpp:29
Manages the life cycle of a process.
Definition: process.hpp:42
bool create_group
Create a new process group or not.
Definition: process.hpp:31
Definition: case_ignore.hpp:23
winss::HandleWrapper stderr_pipe
STDERR pipe.
Definition: process.hpp:34
Base environment.
Definition: environment.hpp:30
std::string cmd
The command and arguments.
Definition: process.hpp:30
winss::Environment * env
The process environment.
Definition: process.hpp:36
winss::HandleWrapper stdin_pipe
STDIN pipe.
Definition: process.hpp:35
winss::HandleWrapper stdout_pipe
STDOUT pipe.
Definition: process.hpp:33