WvStreams
wvstreamlistex2.cc
1 /*
2  * A WvStream example.
3  *
4  * Some text about this example...
5  */
6 
7 #include <wvistreamlist.h>
8 #include <wvpipe.h>
9 
10 int main()
11 {
12  const char *argv1[] = { "sh", "-c",
13  "while :; do echo foo; sleep 3; done", NULL };
14  const char *argv2[] = { "sh", "-c",
15  "while :; do echo snorkle; sleep 1; done", NULL };
16 
17  WvPipe stream1(argv1[0], argv1, false, true, false);
18  WvPipe stream2(argv2[0], argv2, false, true, false);
19  stream1.autoforward(*wvcon);
20  stream2.autoforward(*wvcon);
21 
22  WvIStreamList l;
23  l.append(&stream1, false);
24  l.append(&stream2, false);
25 
26  while (stream1.isok() || stream2.isok())
27  {
28  if (l.select(-1))
29  l.callback();
30  }
31 }
WvPipe
Implementation of a WvPipe stream.
Definition: wvpipe.h:32
WvStream::select
bool select(time_t msec_timeout)
Return true if any of the requested features are true on the stream.
Definition: wvstream.h:376
WvStream::callback
virtual void callback()
if the stream has a callback function defined, call it now.
Definition: wvstream.cc:401
WvIStreamList
WvStreamList holds a list of WvStream objects – and its select() and callback() functions know how to...
Definition: wvistreamlist.h:20