diff options
author | GENIVI Audio Manager Maintainer <genivi-maint-audiomanager@smtp1.genivi.org> | 2017-11-29 18:46:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-29 18:46:45 +0100 |
commit | aa59667c69254b0e2cb43cfcdba8d83db4f26e73 (patch) | |
tree | 394a979b6adf39522c68dda78e541aba1fc13442 /AudioManagerDaemon | |
parent | d244e592eb11b0d46558da129774fe1c79c45f2b (diff) | |
parent | dc16c37e79d356632e230d699932523f5994fef2 (diff) | |
download | audiomanager-aa59667c69254b0e2cb43cfcdba8d83db4f26e73.tar.gz |
Merge pull request #21 from JensLorenz/fixup_signalfd7.6
AMDaemon: set pthread_sigmask for signalfd
Diffstat (limited to 'AudioManagerDaemon')
-rwxr-xr-x | AudioManagerDaemon/src/main.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp index 5c0582e..8271db4 100755 --- a/AudioManagerDaemon/src/main.cpp +++ b/AudioManagerDaemon/src/main.cpp @@ -75,6 +75,9 @@ using namespace am; std::vector<std::string> listCommandPluginDirs; std::vector<std::string> listRoutingPluginDirs; +// List of signals to be handled with signalfd +std::vector<uint8_t> listOfSignalsFD = {SIGHUP, SIGTERM, SIGCHLD}; + //commandline options used by the Audiomanager itself TCLAP::ValueArg<std::string> controllerPlugin("c","controllerPlugin","use controllerPlugin full path with .so ending",false,CONTROLLER_PLUGIN_DIR,"string"); TCLAP::ValueArg<std::string> additionalCommandPluginDirs("L","additionalCommandPluginDirs","additional path for looking for command plugins, can be used after -l option",false," ","string"); @@ -251,7 +254,7 @@ void mainProgram(int argc, char *argv[]) throw std::runtime_error(std::string("CAmSocketHandler: Could not create pipe or file descriptor is invalid.")); } - if( E_OK!=iSocketHandler.listenToSignals({SIGHUP, SIGTERM, SIGCHLD}) ) + if(E_OK != iSocketHandler.listenToSignals(listOfSignalsFD)) { logWarning("CAmSocketHandler failed to register itself as signal handler."); } @@ -399,8 +402,20 @@ int main(int argc, char *argv[], char** envp) //register new out of memory handler std::set_new_handler(&OutOfMemoryHandler); + sigset_t signal_mask; + sigemptyset(&signal_mask); + for (auto it : listOfSignalsFD) + { + sigaddset(&signal_mask, it); + } + try { + if (pthread_sigmask(SIG_BLOCK, &signal_mask, NULL) != 0) + { + throw std::runtime_error(std::string("Couldn't set mask for potential future threads")); + } + //we do this to catch all exceptions and have a graceful ending just in case mainProgram(argc,argv); } |