1 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
2 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
3 // Copyright (c) 2009 Boris Schaeling
4 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
5 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
6 // Copyright (c) 2016 Klemens D. Morgenstern
8 // Distributed under the Boost Software License, Version 1.0. (See accompanying
9 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_PROCESS_POSIX_SIGNAL_HPP
12 #define BOOST_PROCESS_POSIX_SIGNAL_HPP
14 #include <boost/process/detail/posix/handler.hpp>
17 namespace boost { namespace process { namespace detail { namespace posix {
19 #if defined(__GLIBC__)
20 using sighandler_t = ::sighandler_t;
22 using sighandler_t = void(*)(int);
26 struct sig_init_ : handler_base_ext
29 sig_init_ (sighandler_t handler) : _handler(handler) {}
31 template <class PosixExecutor>
32 void on_exec_setup(PosixExecutor&)
34 _old = ::signal(SIGCHLD, _handler);
37 template <class Executor>
38 void on_error(Executor&, const std::error_code &)
42 ::signal(SIGCHLD, _old);
47 template <class Executor>
48 void on_success(Executor&)
52 ::signal(SIGCHLD, _old);
58 ::boost::process::detail::posix::sighandler_t _old{0};
59 ::boost::process::detail::posix::sighandler_t _handler{0};
66 sig_init_ operator()(::boost::process::detail::posix::sighandler_t h) const {return h;}
67 sig_init_ operator= (::boost::process::detail::posix::sighandler_t h) const {return h;}
68 sig_init_ dfl() const {return SIG_DFL;}
69 sig_init_ ign() const {return SIG_IGN;}