@@ -202,6 +202,7 @@ void AnyStream::Close() {
202202 std::basic_streambuf<char > *current=ifStream->std ::ios::rdbuf ();
203203 ifStream->std ::ios::rdbuf (old_rdbuf_in);
204204 old_rdbuf_in=nullptr ;
205+ ispipe = false ;
205206 }
206207 ifStream->close ();
207208 ifStream->clear ();
@@ -211,6 +212,7 @@ void AnyStream::Close() {
211212 std::basic_streambuf<char > *current=ofStream->std ::ios::rdbuf ();
212213 ifStream->std ::ios::rdbuf (old_rdbuf_out);
213214 old_rdbuf_out=nullptr ;
215+ ispipe = false ;
214216 }
215217 ofStream->close ();
216218 ofStream->clear ();
@@ -243,6 +245,7 @@ void AnyStream::OpenAsPipes(const std::string& name_, const std::ios_base::openm
243245 }
244246 old_rdbuf_in = ifStream->std ::ios::rdbuf ();
245247 ifStream->std ::ios::rdbuf (in);
248+ ispipe=true ;
246249 }
247250 if (mode_ & std::ios_base::out) {
248251 stdio_filebuf<char > * out = fileBufFromFD (pipeOutFd, std::ios_base::out);
@@ -256,6 +259,7 @@ void AnyStream::OpenAsPipes(const std::string& name_, const std::ios_base::openm
256259 }
257260 old_rdbuf_out = ofStream->std ::ios::rdbuf ();
258261 ofStream->std ::ios::rdbuf (out);
262+ ispipe=true ;
259263 }
260264 }
261265#else
@@ -403,9 +407,11 @@ bool AnyStream::Eof() {
403407 if (ifStream != NULL ) {
404408 ifStream->clear (); // clear old EOF
405409
406- ifStream->peek (); // trigger EOF if at EOF
407-
408- return ifStream->eof ();
410+ if (ispipe) return true ;
411+ else {
412+ ifStream->peek (); // trigger EOF if at EOF
413+ return ifStream->eof ();
414+ }
409415 }
410416 if (igzStream != NULL ) {
411417 igzStream->clear (); // clear old EOF
0 commit comments