-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.cpp
More file actions
63 lines (54 loc) · 1.57 KB
/
data.cpp
File metadata and controls
63 lines (54 loc) · 1.57 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "data.hpp"
data::data()
{
}
//**************************************************************************************
// function name: findjob
// Description: findes a job by job id
// Parameters: list of jobs and jobid
// Returns: iterator to spesifisied job - FAILES return to end
//**************************************************************************************
std::list<job>::iterator data::findjob(std::list<job> &jobs, int jobID)
{
std::cout << "the int we got is: " << jobID << std::endl;
for(std::list<job>::iterator it = jobs.begin(); it != jobs.end(); it++ ){
if (it->jobid == jobID)
{
std::cout << "the job is is: " << it->jobid << "and the name is: " << it->name << std::endl;
return it;
}
}
return jobs.end();
}
//**************************************************************************************
// function name: checkandbreakprocess
// Description: findes a job and checks if alive - if not cleans it from job list
// Parameters: list of jobs
// Returns: return to end of jobs
//**************************************************************************************
std::list<job>::iterator data::checkandbreakprocess(std::list<job> &items)
{
std::list<job>::iterator i = items.begin();
while (i != items.end())
{
waitpid(-1, NULL, WNOHANG);
if(kill(i->pid ,0) != 0)
{
items.erase(i++);
}
else
{
++i;
}
}
return jobs.end();
}
data::~data()
{
}
job::job()
{
}
job::~job()
{
}