Added os::signals::install to install signal handlers. Review: https://reviews.apache.org/r/32833
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d3bea443 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d3bea443 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d3bea443 Branch: refs/heads/master Commit: d3bea4433fb06011f673335ec81fe6af2c7592b2 Parents: d66d30c Author: Jie Yu <[email protected]> Authored: Fri Apr 3 14:01:37 2015 -0700 Committer: Jie Yu <[email protected]> Committed: Fri Apr 3 14:33:59 2015 -0700 ---------------------------------------------------------------------- .../3rdparty/stout/include/stout/os/signals.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/d3bea443/3rdparty/libprocess/3rdparty/stout/include/stout/os/signals.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/signals.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/signals.hpp index 30232f5..3523070 100644 --- a/3rdparty/libprocess/3rdparty/stout/include/stout/os/signals.hpp +++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/signals.hpp @@ -24,6 +24,17 @@ namespace os { namespace signals { +// Installs the given signal handler. +inline int install(int signal, void(*handler)(int)) +{ + struct sigaction action; + memset(&action, 0, sizeof(action)); + sigemptyset(&action.sa_mask); + action.sa_handler = handler; + return sigaction(signal, &action, NULL); +} + + // Resets the signal handler to the default handler of the signal. inline int reset(int signal) {
