Turi Create  4.0
console_cancel_handler_unix.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef CPPIPC_SERVER_CONSOLE_CANCEL_HANDLER_UNIX_HPP
7 #define CPPIPC_SERVER_CONSOLE_CANCEL_HANDLER_UNIX_HPP
8 
9 #include <csignal>
10 #include <core/system/cppipc/client/console_cancel_handler.hpp>
11 
12 namespace cppipc {
13 
14 class console_cancel_handler_unix : public console_cancel_handler {
15  public:
16  typedef console_cancel_handler super;
17  bool set_handler();
18  bool unset_handler();
19  void raise_cancel();
20  console_cancel_handler_unix();
21 
22  private:
23 
24  struct sigaction m_sigint_act;
25  struct sigaction m_prev_sigint_act;
26 };
27 
28 } // namespace cppipc
29 
30 #endif //CPPIPC_SERVER_CONSOLE_CANCEL_HANDLER_UNIX_HPP