32 #ifdef HAVE_SIGNAL_HANDLING
33 #ifndef _QORE_QORESIGNAL_H
35 #define _QORE_QORESIGNAL_H
37 #include <qore/QoreThreadLock.h>
38 #include <qore/QoreCondition.h>
39 #include <qore/QoreCounter.h>
46 #ifndef QORE_SIGNAL_MAX
48 #define QORE_SIGNAL_MAX (NSIG+1)
50 #define QORE_SIGNAL_MAX _NSIG
52 #define QORE_SIGNAL_MAX _NSIGS
53 #elif defined __DARWIN_NSIG
54 #define QORE_SIGNAL_MAX (__DARWIN_NSIG+1)
56 #error do not know maximum signal number on this platform
61 #define QORE_STATUS_SIGNAL SIGSYS
75 DLLLOCAL CodePgm() : funcref(0), pgm(0) {
95 CodePgm rv(funcref, pgm);
103 DLLLOCAL CodePgm take() {
105 CodePgm rv(funcref, pgm);
113 funcref->
deref(xsink);
121 class QoreSignalHandler :
public CodePgm {
123 enum sh_status_e { SH_OK = 0, SH_InProgress = 1, SH_Delete = 2 };
126 DLLLOCAL
void init();
128 DLLLOCAL
bool isSet()
const {
129 return (
bool)funcref;
137 typedef std::map<int, std::string> sig_map_t;
139 class QoreSignalManager {
140 friend class QoreSignalManagerBusyHelper;
151 DLLLOCAL
void reload();
152 DLLLOCAL
void stop_signal_thread_unlocked();
154 DLLLOCAL
void stop_signal_thread();
155 DLLLOCAL
void setMask(sigset_t& mask);
158 enum sig_cmd_e { C_None = 0, C_Reload = 1, C_Exit = 2 };
168 QoreSignalHandler handlers[QORE_SIGNAL_MAX];
172 DLLLOCAL QoreSignalManager();
173 DLLLOCAL
void init(
bool disable_signal_mask =
false);
177 DLLLOCAL
const char* getSignalName(
int sig);
178 DLLLOCAL
void signal_handler_thread();
179 DLLLOCAL
void lock_idle();
180 DLLLOCAL
void release_idle();
181 DLLLOCAL
void start_handler();
182 DLLLOCAL
void end_handler();
183 DLLLOCAL
void preFork();
184 DLLLOCAL
void postFork(
bool new_process,
ExceptionSink* xsink);
188 DLLLOCAL
void reset_default_signal_mask();
189 DLLLOCAL
bool running() {
return tid != -1; }
190 DLLLOCAL
bool enabled() {
return is_enabled; }
195 DLLLOCAL
QoreStringNode* reassignSignal(
int sig,
const char* name);
198 DLLLOCAL
int releaseSignal(
int sig,
const char* name);
200 DLLLOCAL
int releaseSignals(
const sig_vec_t& sig_vec,
const char* name);
203 DLLLOCAL
extern QoreSignalManager QSM;
std::vector< int > sig_vec_t
signal vector
Definition: QoreLib.h:51
DLLLOCAL void ref() const
increments the reference count of the object
Definition: AbstractPrivateData.h:51
DLLEXPORT void deref(ExceptionSink *xsink)
decrements the reference count and calls derefImpl() if there_can_be_only_one is false,...
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
a thread condition class implementing a wrapper for pthread_cond_t
Definition: QoreCondition.h:45
a simple thread-safe counter object; objects can block on it until the counter reaches zero
Definition: QoreCounter.h:40
supports parsing and executing Qore-language code, reference counted, dynamically-allocated only
Definition: QoreProgram.h:127
virtual DLLEXPORT void deref(ExceptionSink *xsink)
decrements the reference count of the object
Qore's string value type, reference counted, dynamically-allocated only.
Definition: QoreStringNode.h:50
provides a mutually-exclusive thread lock
Definition: QoreThreadLock.h:49
base class for resolved call references
Definition: CallReferenceNode.h:109
DLLLOCAL ResolvedCallReferenceNode * refRefSelf() const
references itself and returns this
Definition: CallReferenceNode.h:138
DLLEXPORT QoreProgram * getProgram()
returns the current QoreProgram
DLLEXPORT int q_gettid() noexcept
returns the current TID number