Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:06

0001 // Copyright (c) 2006, 2007 Julio M. Merino Vidal
0002 // Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
0003 // Copyright (c) 2009 Boris Schaeling
0004 // Copyright (c) 2010 Felipe Tanus, Boris Schaeling
0005 // Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
0006 // Copyright (c) 2016 Klemens D. Morgenstern
0007 //
0008 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0009 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
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