-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCLProcess.cpp
More file actions
49 lines (39 loc) · 722 Bytes
/
CLProcess.cpp
File metadata and controls
49 lines (39 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "CLProcess.h"
#include "CLLogger.h"
#include <errno.h>
#include <stdlib.h>
#include <iostream>
#include <sys/wait.h>
using namespace std;
CLProcess::CLProcess()
{
}
CLProcess::~CLProcess()
{
}
CLStatus CLProcess::Run(void *pContext)
{
m_ProcessID = fork();
if(m_ProcessID == 0)
{
m_ProcessID = getpid();
StartFunctionProcess(pContext);
exit(0);
}
else if(m_ProcessID == -1)
{
CLLogger::WriteLogMsg("In CLProcess::Run(), fork error", errno);
return CLStatus(-1, 0);
}
else
return CLStatus(0, 0);
}
CLStatus CLProcess::WaitForDeath()
{
if(m_ProcessID == -1)
return CLStatus(-1, 0);
if(waitpid(m_ProcessID, 0, 0) == -1)
return CLStatus(-1, errno);
else
return CLStatus(0, 0);
}