WvStreams
Main Page
Modules
Classes
Files
File List
File Members
Docs
sgmlmanual
egfiles
wvpipelogex.cc
1
/*
2
* A WvPipe and WvLog example.
3
*
4
* This program allows you to enter bash commands, runs them, and pipes the
5
* output back to you
6
*/
7
8
#include "wvpipe.h"
9
#include "wvlog.h"
10
11
int
main(
int
argc,
char
**argv)
12
{
13
const
char
*_av[] = {
14
"/bin/bash"
,
15
NULL
16
};
17
const
char
**av = (argc < 2) ? _av : (
const
char
**)(argv + 1);
18
19
WvLog
log(av[0]);
20
WvPipe
p(av[0], av,
true
,
false
,
false
);
21
22
wvcon->
autoforward
(p);
23
p.autoforward(*wvcon);
24
25
p.write(
"test string\r\n"
);
26
27
while
(p.isok() && wvcon->
isok
())
28
{
29
if
(p.select(100))
30
p.callback();
31
if
(wvcon->
select
(100))
32
wvcon->
callback
();
33
}
34
35
p.flush_then_close(50000);
36
while
(p.isok())
37
{
38
log(
"Flushing...\n"
);
39
if
(p.select(1000))
40
p.callback();
41
}
42
43
if
(p.child_exited())
44
log(WvLog::Notice,
"Exited (return code == %s)\n"
,
45
p.exit_status());
46
47
_exit(0);
// don't kill the subtask
48
49
return
0;
50
}
Generated on Fri Mar 14 2014 14:08:53 for WvStreams by
1.8.1.2