36 int flags = ::fcntl( fd, F_GETFL );
43 flags = flags | O_NONBLOCK;
44 else if ( flags & O_NONBLOCK )
45 flags = flags ^ O_NONBLOCK;
47 flags = ::fcntl( fd,F_SETFL,flags );
87 FILE * inputfile = file;
91 int inputfileFd = ::fileno( inputfile );
93 size_t linebuffer_size = 0;
107 int remainingTimeout =
static_cast<int>( timeout );
119 fd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
123 g_timer_start( timer );
125 clearerr( inputfile );
127 int retval = g_poll( &fd, 1, remainingTimeout );
130 if ( errno != EINTR ) {
131 ERR <<
"select error: " << strerror(errno) << std::endl;
138 ssize_t nread = getdelim( &linebuf.
value(), &linebuffer_size, c, inputfile );
140 if ( ::feof( inputfile ) )
146 line += std::string( linebuf, nread );
148 if ( ! ::ferror( inputfile ) || ::feof( inputfile ) ) {
157 remainingTimeout -= g_timer_elapsed( timer,
nullptr ) * 1000;
158 if ( remainingTimeout <= 0 )
174 std::vector<char> data( count + 1 ,
'\0' );
177 while ((l = pread( fileno( fd ), data.data(), count, offset ) ) == -1 && errno == EINTR)