avoid exceptions
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user