* src/misc/satsolver.cc: Report when SAT-solver terminate by signal.
This commit is contained in:
parent
22f944ad56
commit
88cd81c547
1 changed files with 21 additions and 1 deletions
|
|
@ -25,6 +25,7 @@
|
||||||
#include "satsolver.hh"
|
#include "satsolver.hh"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -58,7 +59,26 @@ namespace spot
|
||||||
declare('O', out);
|
declare('O', out);
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
format(s, satsolver);
|
format(s, satsolver);
|
||||||
return system(s.str().c_str());
|
int res = system(s.str().c_str());
|
||||||
|
if (res < 0 || (WIFEXITED(res) && WEXITSTATUS(res) == 127))
|
||||||
|
{
|
||||||
|
s << ": failed to execute";
|
||||||
|
throw std::runtime_error(s.str());
|
||||||
|
}
|
||||||
|
// For POSIX shells, "The exit status of a command that
|
||||||
|
// terminated because it received a signal shall be reported
|
||||||
|
// as greater than 128."
|
||||||
|
if (WIFEXITED(res) && WEXITSTATUS(res) >= 128)
|
||||||
|
{
|
||||||
|
s << ": terminated by signal";
|
||||||
|
throw std::runtime_error(s.str());
|
||||||
|
}
|
||||||
|
if (WIFSIGNALED(res))
|
||||||
|
{
|
||||||
|
s << ": terminated by signal " << WTERMSIG(res);
|
||||||
|
throw std::runtime_error(s.str());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue