xref: /aosp_15_r20/external/deqp/framework/delibs/decpp/deProcess.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements C++ Base Library
3  * -----------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief deProcess C++ wrapper.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "deProcess.hpp"
25 
26 #include <new>
27 
28 namespace de
29 {
30 
Process(void)31 Process::Process(void) : m_process(deProcess_create())
32 {
33     if (!m_process)
34         throw std::bad_alloc();
35 }
36 
~Process(void)37 Process::~Process(void)
38 {
39     deProcess_destroy(m_process);
40 }
41 
start(const char * commandLine,const char * workingDirectory)42 void Process::start(const char *commandLine, const char *workingDirectory)
43 {
44     if (!deProcess_start(m_process, commandLine, workingDirectory))
45         throw ProcessError(deProcess_getLastError(m_process));
46 }
47 
waitForFinish(void)48 void Process::waitForFinish(void)
49 {
50     if (!deProcess_waitForFinish(m_process))
51         throw ProcessError(deProcess_getLastError(m_process));
52 }
53 
terminate(void)54 void Process::terminate(void)
55 {
56     if (!deProcess_terminate(m_process))
57         throw ProcessError(deProcess_getLastError(m_process));
58 }
59 
kill(void)60 void Process::kill(void)
61 {
62     if (!deProcess_kill(m_process))
63         throw ProcessError(deProcess_getLastError(m_process));
64 }
65 
closeStdIn(void)66 void Process::closeStdIn(void)
67 {
68     if (!deProcess_closeStdIn(m_process))
69         throw ProcessError(deProcess_getLastError(m_process));
70 }
71 
closeStdOut(void)72 void Process::closeStdOut(void)
73 {
74     if (!deProcess_closeStdOut(m_process))
75         throw ProcessError(deProcess_getLastError(m_process));
76 }
77 
closeStdErr(void)78 void Process::closeStdErr(void)
79 {
80     if (!deProcess_closeStdErr(m_process))
81         throw ProcessError(deProcess_getLastError(m_process));
82 }
83 
84 } // namespace de
85