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

@ -31,6 +31,7 @@
#include "error.h"
#include "common_output.hh"
#include "common_cout.hh"
#include "common_r.hh"
#include "misc/_config.h"
@ -384,6 +385,7 @@ namespace
std::cout << input << std::endl;
else
assert(error_style == drop_errors);
check_cout();
return !quiet;
}
@ -474,7 +476,6 @@ namespace
one_match = true;
output_formula(f);
}
f->destroy();
return 0;
}
@ -512,16 +513,16 @@ run_jobs()
spot::ltl::ltl_simplifier simpl(simplifier_options());
ltl_processor processor(simpl);
int error = 0;
int nerror = 0;
jobs_t::const_iterator i;
for (i = jobs.begin(); i != jobs.end(); ++i)
{
if (!i->file_p)
error |= processor.process_formula(i->str);
nerror |= processor.process_formula(i->str);
else
error |= processor.process_file(i->str);
nerror |= processor.process_file(i->str);
}
if (error)
if (nerror)
return 2;
return one_match ? 0 : 1;
}