-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForeJob.h
executable file
·78 lines (55 loc) · 1.97 KB
/
ForeJob.h
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* file: ForeJob.h
Foreground Job Class Header File
==================================================
Wimpy Shell Project - Com Sci 342
Shea Daniels
This class is based around the code needed to redirect,
execute, and wait for a foreground job.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Information on constructors: !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ForeJob(Command new_command)
--------------------------------------------------
This is the basic constructor for the class.
PRE: new_command must a parsed Command object.
POST: new_command is now the value of this
oject's command.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! Information on public methods: !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
bool execute()
--------------------------------------------------
Tries to execute the job and then wait for it
to finish running.
POST: Returns true if the job was successfully
started and finished. Returns false if
there was an error.
*/
#ifndef FORE_HEADER
#define FORE_HEADER
#include <string>
#include <vector>
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <errno.h>
#include "Command.h"
using namespace std;
class ForeJob {
public:
// constructor
ForeJob(Command new_command);
// execute the job
bool execute();
private:
// redirection commands
void redirectOutput();
void redirectInput();
//------------------------------------------------------------
// Data
//------------------------------------------------------------
Command my_command;
};
#endif