Changeset 149:70d2c2edc0f1 in finroc_plugins_structure


Ignore:
Timestamp:
01.11.2021 20:17:18 (2 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Parents:
146:a4bae722af30 (diff), 148:bc0f6205fb43 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Tags:
tip
Message:

Merge with 17.03

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main_utilities.cpp

    r146 r149  
    3636//---------------------------------------------------------------------- 
    3737#include <cstdlib> 
    38 #include <csignal> 
    3938#include <mutex> 
    4039#include <condition_variable> 
     
    6766 
    6867#include "rrlib/getopt/parser.h" 
     68#include "rrlib/util/tSignalHandler.h" 
    6969 
    7070//---------------------------------------------------------------------- 
     
    341341} 
    342342 
     343class tSignalHandler : public rrlib::util::tSignalHandler 
     344{ 
     345  virtual void OnSignal(int signal, bool& exit) override 
     346  { 
     347    if (signal == SIGINT) 
     348    { 
     349      HandleSignalSIGINT(signal); 
     350    } 
     351    else if (signal == SIGTERM) 
     352    { 
     353      HandleSignalSIGTERM(signal); 
     354    } 
     355    exit = false; 
     356  } 
     357} signal_handler; 
     358 
    343359} 
    344360 
     
    348364bool InstallSignalHandler() 
    349365{ 
    350 #if __linux__ 
    351   struct sigaction signal_action; 
    352   signal_action.sa_handler = HandleSignalSIGINT; 
    353   sigemptyset(&signal_action.sa_mask); 
    354   signal_action.sa_flags = 0; 
    355  
    356   if (sigaction(SIGINT, &signal_action, NULL) != 0) 
    357   { 
    358     perror("Could not install signal handler"); 
    359     return false; 
    360   } 
    361  
    362   signal_action.sa_handler = HandleSignalSIGTERM; 
    363   if (sigaction(SIGTERM, &signal_action, NULL) != 0) 
    364   { 
    365     perror("Could not install signal handler"); 
    366     return false; 
    367   } 
    368  
    369 #else 
    370   signal(SIGINT, HandleSignalSIGINT); 
    371   signal(SIGTERM, HandleSignalSIGTERM); 
    372 #endif 
    373  
     366  if (!signal_handler.CatchedSignalMask()) 
     367  { 
     368    return signal_handler.CatchSignal(SIGINT) && signal_handler.CatchSignal(SIGTERM); 
     369  } 
    374370  return true; 
    375371} 
Note: See TracChangeset for help on using the changeset viewer.