File: whichstream.cc

package info (click to toggle)
bobcat 2.08.01-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,668 kB
  • ctags: 953
  • sloc: cpp: 10,403; makefile: 9,042; perl: 401; sh: 195
file content (25 lines) | stat: -rw-r--r-- 619 bytes parent folder | download
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
#include "process.ih"

size_t Process::whichStream()
{
    d_selector.wait();

    switch (size_t count = d_selector.nReady())
    {
        case 0:
        return NOTHING_AVAILABLE;

        case 1:
        return d_selector.readFd() == d_child_outp->readFd() ? 
                    CHILD_COUT 
                : 
                    CHILD_CERR;
        case 2:
        return CHILD_COUT | CHILD_CERR;

        default:
            throw Errno("Process::whichStream(): internal error. "
                "d_selector.nReady() returns ") << insertable <<
                count << ", should be <= 2" << throwable;
    }
}