Boost C++ Libraries: Ticket #9476: boost::iostreams::copy - sink - ENOSPC (No space left on device) error handling https://svn.boost.org/trac10/ticket/9476 <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/9476 Trac 1.4.3 viboes Wed, 11 Dec 2013 06:39:27 GMT component changed; owner set https://svn.boost.org/trac10/ticket/9476#comment:1 https://svn.boost.org/trac10/ticket/9476#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Jonathan Turkanis</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">iostreams</span> </li> </ul> Ticket