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 );
136 ssize_t nread =
zyppng::eintrSafeCallEx( ::getdelim, [&](){ clearerr( inputfile ); }, &linebuf.
value(), &linebuffer_size, c, inputfile );
138 if ( ::feof( inputfile ) ) {
141 if ( errno != EAGAIN && ( ::ferror( inputfile ) || errno != 0 ) ) {
143 else ERR <<
"Unknown getdelim error." << std::endl;
150 line += std::string( linebuf, nread );
152 if ( ! ::ferror( inputfile ) || ::feof( inputfile ) ) {
161 remainingTimeout -= g_timer_elapsed( timer,
nullptr ) * 1000;
162 if ( remainingTimeout <= 0 )
178 std::vector<char> data( count + 1 ,
'\0' );
181 while ((l = pread( fileno( fd ), data.data(), count, offset ) ) == -1 && errno == EINTR)