Boost C++ Libraries: Ticket #9478: boost::iostreams::copy - sink - ENOSPC (No space left on device) error handling https://svn.boost.org/trac10/ticket/9478 <p> Platform: GCC on Linux; boost 1.55. </p> <p> In the code fragment below, is there a way to handle ENOSPC? </p> <pre class="wiki">#include &lt;fstream&gt; #include &lt;iostream&gt; #include &lt;boost/iostreams/filtering_streambuf.hpp&gt; #include &lt;boost/iostreams/copy.hpp&gt; #include &lt;boost/iostreams/filter/bzip2.hpp&gt; // open input file stream of the bzip2 file std::ifstream ifs("file.bz2"); // open output stream to the "full" device // full device is a "utility-device" to check how applications handle ENOSPC // more details in "man full" std::ofstream ofs("/dev/full"); // Setup the iostreams filter boost::iostreams::filtering_streambuf&lt;boost::iostreams::output&gt; filters; filters.push(boost::iostreams::bzip2_decompressor()); filters.push(ofs); // "run" the filter boost::iostreams::copy(ifs, filters); </pre><p> If I do strace of the compiled binary, the code seem to infinitely call writev() with the same data and returns ENOSPC error. </p> <pre class="wiki">writev(4, [{NULL, 0}, {"DATA DATA "..., 4096}], 2) = -1 ENOSPC (No space left on device) </pre><p> How can this error be handled or made thrown as an error from <code>boost::iostreams::copy()</code> </p> <p> Is it possible to set appropriate exceptions() on the ofstream object? I tried <code>ofs.exceptions(std::ios::badbit | std::ios::failbit)</code> but it didn't make any difference. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9478 Trac 1.4.3 dckorah@… Sat, 07 Dec 2013 09:41:01 GMT <link>https://svn.boost.org/trac10/ticket/9478#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9478#comment:1</guid> <description> <p> Sorry to log this again; previous attempts were spoilt by the captcha+https issues. got the categorisation and components wrong. </p> </description> <category>Ticket</category> </item> <item> <author>dckorah@…</author> <pubDate>Sat, 07 Dec 2013 18:57:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9478#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9478#comment:2</guid> <description> <p> Please see more analysis here <a class="ext-link" href="http://stackoverflow.com/q/20414577/83005"><span class="icon">​</span>http://stackoverflow.com/q/20414577/83005</a> </p> </description> <category>Ticket</category> </item> <item> <author>bugs@…</author> <pubDate>Sat, 07 Dec 2013 19:03:05 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/9478 https://svn.boost.org/trac10/ticket/9478 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">test.cpp</span> </li> </ul> <p> more minimal reproducer </p> Ticket