vulp  2.3.0
handle_interrupts.cpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: Apache-2.0
2 // Copyright 2022 Stéphane Caron
3 
5 
6 namespace vulp::utils {
7 
8 namespace internal {
9 
10 bool interrupt_flag = false;
11 
12 void handle_interrupt(int _) { interrupt_flag = true; }
13 
14 } // namespace internal
15 
20 const bool& handle_interrupts() {
21  struct sigaction handler;
22  handler.sa_handler = internal::handle_interrupt;
23  sigemptyset(&handler.sa_mask);
24  handler.sa_flags = 0;
25  sigaction(SIGINT, &handler, NULL);
27 }
28 
29 } // namespace vulp::utils
void handle_interrupt(int _)
Internal handler to set interrupt_flag.
bool interrupt_flag
Internal interrupt flag.
Utility functions.
Definition: __init__.py:1
const bool & handle_interrupts()
Redirect interrupts to setting a global interrupt boolean.