File indexing completed on 2025-01-18 09:50:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_PROCESS_POSIX_SIGNAL_HPP
0012 #define BOOST_PROCESS_POSIX_SIGNAL_HPP
0013
0014 #include <boost/process/detail/posix/handler.hpp>
0015 #include <signal.h>
0016
0017 namespace boost { namespace process { namespace detail { namespace posix {
0018
0019 #if defined(__GLIBC__)
0020 using sighandler_t = ::sighandler_t;
0021 #else
0022 using sighandler_t = void(*)(int);
0023 #endif
0024
0025
0026 struct sig_init_ : handler_base_ext
0027 {
0028
0029 sig_init_ (sighandler_t handler) : _handler(handler) {}
0030
0031 template <class PosixExecutor>
0032 void on_exec_setup(PosixExecutor&)
0033 {
0034 _old = ::signal(SIGCHLD, _handler);
0035 }
0036
0037 template <class Executor>
0038 void on_error(Executor&, const std::error_code &)
0039 {
0040 if (!_reset)
0041 {
0042 ::signal(SIGCHLD, _old);
0043 _reset = true;
0044 }
0045 }
0046
0047 template <class Executor>
0048 void on_success(Executor&)
0049 {
0050 if (!_reset)
0051 {
0052 ::signal(SIGCHLD, _old);
0053 _reset = true;
0054 }
0055 }
0056 private:
0057 bool _reset = false;
0058 ::boost::process::detail::posix::sighandler_t _old{0};
0059 ::boost::process::detail::posix::sighandler_t _handler{0};
0060 };
0061
0062 struct sig_
0063 {
0064 constexpr sig_() {}
0065
0066 sig_init_ operator()(::boost::process::detail::posix::sighandler_t h) const {return h;}
0067 sig_init_ operator= (::boost::process::detail::posix::sighandler_t h) const {return h;}
0068 sig_init_ dfl() const {return SIG_DFL;}
0069 sig_init_ ign() const {return SIG_IGN;}
0070
0071 };
0072
0073
0074
0075
0076
0077 }}}}
0078
0079 #endif