GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
sighandlers.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1993-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 /*
24 
25 The signal blocking macros defined below were adapted from similar
26 functions from GNU Bash, the Bourne Again SHell, copyright (C) 1994
27 Free Software Foundation, Inc.
28 
29 */
30 
31 // This file should always be included after config.h!
32 
33 #if ! defined (octave_sighandlers_h)
34 #define octave_sighandlers_h 1
35 
36 #include "octave-config.h"
37 
38 #include "child-list.h"
39 
40 namespace octave
41 {
42  // This type must match the typedef in signal-wrappers.h.
43  typedef void sig_handler (int);
44 
45  struct
47  {
50  };
51 
52  // Nonzero means we have already printed a message for this series of
53  // SIGPIPES. We assume that the writer will eventually give up.
54  extern int pipe_handler_error_count;
55 
56  // TRUE means we can be interrupted.
57  extern OCTINTERP_API bool can_interrupt;
58 
59  extern OCTINTERP_API sig_handler *
60  set_signal_handler (int sig, sig_handler *h,
61  bool restart_syscalls = true);
62 
63  extern OCTINTERP_API sig_handler *
64  set_signal_handler (const char *signame, sig_handler *h,
65  bool restart_syscalls = true);
66 
67  extern OCTINTERP_API void install_signal_handlers (void);
68 
69  extern OCTINTERP_API void respond_to_pending_signals (void);
70 
71  extern OCTINTERP_API interrupt_handler catch_interrupts (void);
72 
73  extern OCTINTERP_API interrupt_handler ignore_interrupts (void);
74 
75  extern OCTINTERP_API interrupt_handler
76  set_interrupt_handler (const volatile interrupt_handler& h,
77  bool restart_syscalls = true);
78 
79  // TRUE means we should try to enter the debugger on SIGINT.
80  extern OCTINTERP_API bool Vdebug_on_interrupt;
81 }
82 
83 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
84 
85 OCTAVE_DEPRECATED (4.2, "use 'octave::interrupt_handler' instead")
86 typedef octave::interrupt_handler octave_interrupt_handler;
87 
88 OCTAVE_DEPRECATED (4.2, "use 'octave::sig_handler' instead")
90 
91 OCTAVE_DEPRECATED (4.2, "use 'octave::pipe_handler_error_count' instead")
93 
94 OCTAVE_DEPRECATED (4.2, "use 'octave::can_interrupt' instead")
95 static auto& can_interrupt = octave::can_interrupt;
96 
97 OCTAVE_DEPRECATED (4.2, "use 'octave::set_signal_handler' instead")
98 inline octave::sig_handler *
99 octave_set_signal_handler (int sig, octave::sig_handler *handler,
100  bool restart_syscalls = true)
101 {
102  return octave::set_signal_handler (sig, handler, restart_syscalls);
103 }
104 
105 OCTAVE_DEPRECATED (4.2, "use 'octave::set_signal_handler' instead")
106 inline octave::sig_handler *
107 octave_set_signal_handler (const char *signame, octave::sig_handler *handler,
108  bool restart_syscalls = true)
109 {
110  return octave::set_signal_handler (signame, handler, restart_syscalls);
111 }
112 
113 OCTAVE_DEPRECATED (4.2, "use 'octave::set_signal_handler' instead")
115 
116 OCTAVE_DEPRECATED (4.2, "use 'octave::respond_to_pending_signals' instead")
117 const auto octave_signal_handler = octave::respond_to_pending_signals;
118 
119 namespace octave
120 {
121  OCTAVE_DEPRECATED (4.4, "use 'octave::respond_to_pending_signals' instead")
122  const auto signal_handler = respond_to_pending_signals;
123 }
124 
125 OCTAVE_DEPRECATED (4.2, "use 'octave::interrupt_handler' instead")
126 const auto octave_catch_interrupts = octave::catch_interrupts;
127 
128 OCTAVE_DEPRECATED (4.2, "use 'octave::ignore_interrupts' instead")
129 const auto octave_ignore_interrupts = octave::ignore_interrupts;
130 
131 OCTAVE_DEPRECATED (4.2, "use 'octave::set_interrupt_handler' instead")
132 const auto octave_set_interrupt_handler = octave::set_interrupt_handler;
133 
134 OCTAVE_DEPRECATED (4.2, "use 'octave::Vdebug_on_interrupt' instead")
136 
137 #endif
138 
139 #endif
interrupt_handler catch_interrupts(void)
Definition: sighandlers.cc:323
void sig_handler(int)
Definition: sighandlers.h:43
void octave_sig_handler(int)
void respond_to_pending_signals(void)
Definition: sighandlers.cc:106
bool can_interrupt
Definition: sighandlers.cc:68
sig_handler * set_signal_handler(int sig, sig_handler *handler, bool restart_syscalls)
Definition: sighandlers.cc:256
double h
Definition: graphics.cc:11808
bool Vdebug_on_interrupt
Definition: sighandlers.cc:71
int pipe_handler_error_count
Definition: sighandlers.cc:65
sig_handler * brk_handler
Definition: sighandlers.h:49
sig_handler * int_handler
Definition: sighandlers.h:48
interrupt_handler ignore_interrupts(void)
Definition: sighandlers.cc:334
interrupt_handler set_interrupt_handler(const volatile interrupt_handler &h, bool restart_syscalls)
Definition: sighandlers.cc:345
void install_signal_handlers(void)
Definition: sighandlers.cc:362