7 #include <sys/select.h>
19 #ifndef WIBBLE_SYS_PIPE_H
20 #define WIBBLE_SYS_PIPE_H
25 namespace wexcept = wibble::exception;
77 void run(
int _fd, std::string what ) {
104 if ( fcntl(
fd, F_SETFL, O_NONBLOCK ) == -1 )
136 return err == EAGAIN || err == EWOULDBLOCK;
138 return err == EAGAIN;
145 int r = ::read(
fd, _buffer, 1023 );
146 if ( r == -1 && !
blocking( errno ) )
153 std::copy( _buffer, _buffer + r, std::back_inserter(
buffer ) );
167 while ( nl ==
buffer.end() ) {
172 std::string line(
buffer.begin(), nl );
194 #pragma GCC diagnostic push
195 #pragma GCC diagnostic ignored "-Wold-style-cast"
197 select(
fd + 1, &fds, 0, 0, 0 );
198 #pragma GCC diagnostic pop
226 std::string
run( std::string data ) {
238 Pipe in( _in ), out( _out );
243 while ( !out.
eof() ) {