[Boost-bugs] [Boost C++ Libraries] #9478: boost::iostreams::copy - sink - ENOSPC (No space left on device) error handling

Subject: [Boost-bugs] [Boost C++ Libraries] #9478: boost::iostreams::copy - sink - ENOSPC (No space left on device) error handling
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-12-07 09:39:47


#9478: boost::iostreams::copy - sink - ENOSPC (No space left on device) error
handling
------------------------------+-----------------------
 Reporter: dckorah@… | Owner: turkanis
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: iostreams
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
------------------------------+-----------------------
 Platform: GCC on Linux; boost 1.55.

 In the code fragment below, is there a way to handle ENOSPC?

 {{{
 #include <fstream>
 #include <iostream>
 #include <boost/iostreams/filtering_streambuf.hpp>
 #include <boost/iostreams/copy.hpp>
 #include <boost/iostreams/filter/bzip2.hpp>

 // 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<boost::iostreams::output> filters;
 filters.push(boost::iostreams::bzip2_decompressor());
 filters.push(ofs);

 // "run" the filter
 boost::iostreams::copy(ifs, filters);
 }}}

 If I do strace of the compiled binary, the code seem to infinitely call
 writev() with the same data and returns ENOSPC error.

 {{{
 writev(4, [{NULL, 0}, {"DATA DATA "..., 4096}], 2) = -1 ENOSPC (No space
 left on device)
 }}}

 How can this error be handled or made thrown as an error from
 `boost::iostreams::copy()`

 Is it possible to set appropriate exceptions() on the ofstream object? I
 tried `ofs.exceptions(std::ios::badbit | std::ios::failbit)` but it didn't
 make any difference.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9478>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC