Detect fail conditions on std::cout in user's tools.

* src/bin/common_cout.cc, src/bin/common_cout.hh: New files.
* src/bin/Makefile.am: Add them.
* src/bin/ltl2tgba.cc, src/bin/ltlfilt.cc, src/bin/common_output.cc:
Report error when writing to std::cout failed.  This is mainly
motivated by ltlfilt not being killed by SIGPIPE on lip6's OSX
buildfarm (SIGPIPE is probably ignored when the build is started), but
it could detect other errors such as a disk full.
This commit is contained in:
Alexandre Duret-Lutz 2012-09-14 09:45:40 +02:00
parent 70f51b2786
commit 807834ec41
6 changed files with 82 additions and 7 deletions

View file

@ -22,6 +22,7 @@
#include "common_output.hh"
#include <iostream>
#include "ltlvisit/tostring.hh"
#include "common_cout.hh"
#define OPT_SPOT 1
@ -79,5 +80,8 @@ output_formula(const spot::ltl::formula* f)
spot::ltl::to_utf8_string(f, std::cout, full_parenth);
break;
}
std::cout << "\n";
// Make sure we abort if we can't write to std::cout anymore
// (like disk full or broken pipe with SIGPIPE ignored).
std::cout << std::endl;
check_cout();
}