avoid exceptions
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
2023-03-08 14:50:25 +01:00
parent 0bdc6d3d7c
commit ccf03b131b
19 changed files with 83 additions and 45 deletions

View File

@ -18,8 +18,9 @@
WatchdogTask::WatchdogTask() : fd(0) {
int result = 0;
std::error_code e;
// Only create the FIFO if it does not exist yet
if (not std::filesystem::exists(watchdog::FIFO_NAME)) {
if (not std::filesystem::exists(watchdog::FIFO_NAME, e)) {
// Permission 666 or rw-rw-rw-
mode_t mode = DEFFILEMODE;
result = mkfifo(watchdog::FIFO_NAME.c_str(), mode);
@ -167,7 +168,8 @@ int WatchdogTask::performRunningOperation() {
std::cout << "OBSW is running" << std::endl;
#if WATCHDOG_CREATE_FILE_IF_RUNNING == 1
std::cout << "Creating " << watchdog::RUNNING_FILE_NAME << std::endl;
if (not std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) {
std::error_code e;
if (not std::filesystem::exists(watchdog::RUNNING_FILE_NAME, e)) {
std::ofstream obswRunningFile(watchdog::RUNNING_FILE_NAME);
if (not obswRunningFile.good()) {
std::cerr << "Creating file " << watchdog::RUNNING_FILE_NAME << " failed" << std::endl;
@ -196,7 +198,8 @@ int WatchdogTask::performNotRunningOperation(LoopResult type) {
if (obswRunning) {
#if WATCHDOG_CREATE_FILE_IF_RUNNING == 1
std::cout << "Removing " << watchdog::RUNNING_FILE_NAME << std::endl;
if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) {
std::error_code e;
if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME, e)) {
int result = std::remove(watchdog::RUNNING_FILE_NAME.c_str());
if (result != 0) {
std::cerr << "Removing " << watchdog::RUNNING_FILE_NAME << " failed with code " << errno