• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (C) 2011 The Android Open Source Project
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 #ifndef _OSUTILS_PROCESS_H
17 #define _OSUTILS_PROCESS_H
18 
19 #ifdef _WIN32
20 #include <windows.h>
21 #endif
22 
23 namespace osUtils {
24 
25 class childProcess
26 {
27 public:
28     static childProcess *create(const char *p_cmdLine, const char *p_startdir);
29     ~childProcess();
30 
getPID()31     int getPID()
32     {
33 #ifdef _WIN32
34         return m_proc.dwProcessId;
35 #else
36         return(m_pid);
37 #endif
38     }
39 
40     int tryWait(bool& isAlive);
41     bool wait(int *exitStatus);
42 
43 private:
childProcess()44     childProcess() {};
45 
46 private:
47 #ifdef _WIN32
48     PROCESS_INFORMATION m_proc;
49 #else
50     int m_pid;
51 #endif
52 };
53 
54 int ProcessGetPID();
55 int ProcessGetTID();
56 bool ProcessGetName(char *p_outName, int p_outNameLen);
57 int KillProcess(int pid, bool wait);
58 bool isProcessRunning(int pid);
59 
60 } // of namespace osUtils
61 
62 #endif
63