Boost C++ Libraries: Ticket #6576: boost:::iostreams::file_descriptor throws instead of reading EOF on pipe https://svn.boost.org/trac10/ticket/6576 <p> when using file_descriptor to read from a pipe on windows, an exception can be thrown if the write-side has broken the pipe - eg by exiting if it's another process. </p> <p> This is how I used the read-side of the pipe to trigger the failure (if you need a complete minimal sample including windows pipe and process handling code, please ask). I just used <a class="missing wiki">CreateProcess</a> to start a cmd.exe shell script that echo'd a couple of lines to stdout. The pipe has less than the default buffer size written before the write side is closed: </p> <p> file_descriptor fd(pipe_read_side_handle); newline_filter nl(newline::posix); filtered_istream fs; fs.push(nl); fs.push(fd); string str; getline(fs, str); </p> <p> <em> fs.good() is now false </em></p> <p> <em> expected: fs.good() should be true here getline(fs, str); getline(fs, str); </em>... <em> eventually fs.eof() should be true getline(fs, str); </em> one more getline <em> then fs.fail() should be true. </em> I think there are a few different behaviours depending on <em> whether there is a trailing newline or not </em> but I think fs.badbit should not be set </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6576 Trac 1.4.3 anonymous Sat, 18 Feb 2012 16:50:39 GMT attachment set https://svn.boost.org/trac10/ticket/6576 https://svn.boost.org/trac10/ticket/6576 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">file_descriptor.cpp</span> </li> </ul> <p> fixed version of file_descriptor.cpp </p> Ticket boris@… Sun, 29 Jul 2012 13:49:29 GMT attachment set https://svn.boost.org/trac10/ticket/6576 https://svn.boost.org/trac10/ticket/6576 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test1.cpp</span> </li> </ul> <p> Throws when read-end is closed </p> Ticket boris@… Sun, 29 Jul 2012 13:50:26 GMT attachment set https://svn.boost.org/trac10/ticket/6576 https://svn.boost.org/trac10/ticket/6576 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test2.cpp</span> </li> </ul> <p> Returns 0 instead of -1 when write-end is closed </p> Ticket boris@… Sun, 29 Jul 2012 13:51:42 GMT <link>https://svn.boost.org/trac10/ticket/6576#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6576#comment:1</guid> <description> <p> I can confirm the bug (tested with Boost 1.50.0). I can also confirm that the proposed bug fix works (file_descriptor_impl::read should return -1 when <a class="missing wiki">GetLastError</a> returns ERROR_BROKEN_PIPE). I've attached two test programs which can be used to reproduce the problem and to test a possible fix. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Wed, 08 Aug 2012 02:24:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6576#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6576#comment:2</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/79919" title="Fix throwing error; Refs #6576">[79919]</a>) Fix throwing error; Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6576" title="#6576: Bugs: boost:::iostreams::file_descriptor throws instead of reading EOF on pipe (closed: fixed)">#6576</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Sat, 11 Aug 2012 15:07:18 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6576#comment:3 https://svn.boost.org/trac10/ticket/6576#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/79970" title="Merging to release; Fixes #6576">[79970]</a>) Merging to release; Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6576" title="#6576: Bugs: boost:::iostreams::file_descriptor throws instead of reading EOF on pipe (closed: fixed)">#6576</a> </p> Ticket