Browse Source

Implementing non-blocking read.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@53 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz 10 years ago
parent
commit
f1001bc789
2 changed files with 12 additions and 9 deletions
  1. 1
    1
      child.cpp
  2. 11
    8
      child.hpp

+ 1
- 1
child.cpp View File

@@ -219,7 +219,7 @@ namespace CodeDweller {
throw std::runtime_error("Error creating pipe for stdin: " +
getErrorText());
}
if (pipe(childStdOutPipe) != 0) {
if (pipe(childStdOutPipe, O_NONBLOCK) != 0) {
close(childStdInPipe[0]);
close(childStdInPipe[1]);
throw std::runtime_error("Error creating pipe for stdout: " +

+ 11
- 8
child.hpp View File

@@ -97,6 +97,9 @@ namespace CodeDweller {
/// Override streambuf::underflow().
int_type underflow();

/// Fill the buffer.
//void fillBuffer();

/// Copy constructor not implemented.
ReadStreambuf(const ReadStreambuf &);

@@ -222,6 +225,14 @@ namespace CodeDweller {
/// Input stream to read data from the child's standard output.
std::istream reader;

/** Get the number of bytes available for input.

@returns number of bytes that can be read from reader without
blocking.

*/
ssize_t inputBytesAvailable();

/// Output stream to write data to the child's standard input.
std::ostream writer;

@@ -232,14 +243,6 @@ namespace CodeDweller {
*/
void run();

/** Check if input is available.

\returns true if at least one character is available for
reading.

*/
//bool hasData();

/** Terminite the child process.

\throws runtime_error if an error occurs.

Loading…
Cancel
Save