-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_test.cpp
More file actions
49 lines (41 loc) · 1.14 KB
/
process_test.cpp
File metadata and controls
49 lines (41 loc) · 1.14 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
#include <cstdlib>
#include <cstdio>
#include <unistd.h>
#include <iostream>
#include <sstream>
#include <memory>
#include "Process.hpp"
int main(int argc, char *argv[])
{
using namespace std;
std::vector<std::string> args;
if( argc < 2)
{
std::cerr << "This application requires at least two command lined arguments" << std::endl;
std::cerr << "The application must be executed with at least one system call" << std::endl;
return(EXIT_FAILURE);
}
for(int nn=1; nn<argc; ++nn)
{
std::cerr << "Arg: " << argv[nn] << std::endl;
args.push_back(argv[nn]);
}
// args.push_back( NULL );
string output;
{
Process myproc(args,true);
for(int n=0; n<5; ++n) {
stringstream ss;
ss << "1+" << n << endl;
cerr << "calling write with line=" << ss.str() << "END" << endl;
myproc.write(ss.str());
output = myproc.read();
cerr << "output from process: " << output << "END" << endl;
}
//sleep(5);
}
cerr << "Process object destroyed" << endl;
cerr << "Program exiting. Confirm child process has been cleaned up." << endl;
//sleep(5);
return(EXIT_SUCCESS);
}