28 int fd = ::fileno( file );
33 int flags = ::fcntl( fd, F_GETFL );
40 flags = flags | O_NONBLOCK;
41 else if ( flags & O_NONBLOCK )
42 flags = flags ^ O_NONBLOCK;
44 flags = ::fcntl( fd,F_SETFL,flags );
54 FILE * inputfile = file;
58 int inputfileFd = ::fileno( inputfile );
60 size_t linebuffer_size = 0;
74 int remainingTimeout =
static_cast<int>(
timeout );
86 fd.events = G_IO_IN | G_IO_HUP | G_IO_ERR;
90 g_timer_start( timer );
92 clearerr( inputfile );
94 int retval = g_poll( &fd, 1,
timeout );
97 ERR <<
"select error: " <<
strerror(errno) << std::endl;
104 ssize_t nread = getdelim( &linebuf.
value(), &linebuffer_size, c, inputfile );
106 if ( ::feof( inputfile ) )
112 line += std::string( linebuf, nread );
114 if ( ! ::ferror( inputfile ) || ::feof( inputfile ) ) {
123 remainingTimeout -= g_timer_elapsed( timer,
nullptr );
124 if ( remainingTimeout <= 0 )