summaryrefslogtreecommitdiff
path: root/src/components/utils/src/signals_linux.cc
diff options
context:
space:
mode:
authorJustin Dickow <jjdickow@gmail.com>2014-10-27 16:59:35 -0400
committerJustin Dickow <jjdickow@gmail.com>2014-10-27 16:59:35 -0400
commit1ad35342dfe2f92bc1deb734de504177596fc8d6 (patch)
treeb655799ef580fae979e1e66bf3b82dfdd3d42f45 /src/components/utils/src/signals_linux.cc
parent9da0cfe821c3c9252a543e1e4a344867de9dceee (diff)
downloadsdl_core-1ad35342dfe2f92bc1deb734de504177596fc8d6.tar.gz
3.10.1
Signed-off-by: Justin Dickow <jjdickow@gmail.com>
Diffstat (limited to 'src/components/utils/src/signals_linux.cc')
-rw-r--r--src/components/utils/src/signals_linux.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/components/utils/src/signals_linux.cc b/src/components/utils/src/signals_linux.cc
index f592a1e22b..3ded6a5877 100644
--- a/src/components/utils/src/signals_linux.cc
+++ b/src/components/utils/src/signals_linux.cc
@@ -30,15 +30,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <csignal>
+#include <cstdlib>
#include <stdint.h>
namespace utils {
bool SubscribeToTerminateSignal(void (*func)(int32_t p)) {
- void (*prev_func)(int32_t p);
+ struct sigaction act;
+ act.sa_handler = func;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
- prev_func = signal(SIGINT, func);
- return (SIG_ERR != prev_func);
+ return (sigaction(SIGINT, &act, NULL) == 0)
+ && (sigaction(SIGTERM, &act, NULL) == 0);
}
bool ResetSubscribeToTerminateSignal() {