Revision: | 1.1 |
Committed: | Tue Mar 6 00:41:30 2001 UTC (23 years, 8 months ago) by ab11 |
Branch: | MAIN |
Log Message: | Used to unfork() from iopipestream forks and free up file handles (was running out after a while). |
# | User | Rev | Content |
---|---|---|---|
1 | ab11 | 1.1 | #include "SubPipe.h" |
2 | |||
3 | SubPipe::SubPipe(string command){ | ||
4 | |||
5 | p = new iopipestream("statgrab.pl"); | ||
6 | pid = (*p).pid(); | ||
7 | |||
8 | } // subPipe | ||
9 | |||
10 | |||
11 | int SubPipe::getLine(string * fillme){ | ||
12 | |||
13 | int bob = 2048; | ||
14 | char input[bob]; | ||
15 | |||
16 | if ( (*p).getline(input, bob-1) ){ | ||
17 | string sinput = input; | ||
18 | *fillme = sinput; | ||
19 | return 0; | ||
20 | } else { | ||
21 | return 1; | ||
22 | } // if | ||
23 | |||
24 | } // getLine | ||
25 | |||
26 | SubPipe::~SubPipe(){ | ||
27 | |||
28 | // wait for process to finish first | ||
29 | waitpid(pid , 0, 0); | ||
30 | delete p; | ||
31 | |||
32 | } // ~SubPipe | ||
33 |