added a very simple App::guardProcess() function

This commit is contained in:
2018-09-05 14:52:51 +00:00
parent 6f314b0dd8
commit e8804b20ec
5 changed files with 62 additions and 21 deletions

View File

@ -53,6 +53,23 @@ public:
virtual void on_signal (int sig) { }
int subscribeToSignal (int sig, bool accept);
void unsubscribeFromSignal (int sig);
typedef void (*SignalHandler) (int sig);
static qse_size_t _sighrs[2][QSE_NSIGS];
// You may set a global signal handler with setSignalHandler().
// If an application is subscribing to a single with subscribeToSignal(),
// this function is doomed to fail. If a successful call to
// setSignalHandler() has been made withoutut unsetSingalHandler() called
// yet, a subsequence call to subscribeToSignal() is doomed to fail too.
// These two different interfaces are mutually exclusive.
static int setSignalHandler (int sig, SignalHandler sighr);
static int unsetSignalHandler (int sig);
int guardProcess (const qse_mchar_t* proc_name);
protected:
bool _root_only;
@ -78,21 +95,6 @@ public:
_SigLink _sig[QSE_NSIGS];
typedef void (*SignalHandler) (int sig);
static qse_size_t _sighrs[2][QSE_NSIGS];
int subscribeToSignal (int sig, bool accept);
void unsubscribeFromSignal (int sig);
// You may set a global signal handler with setSignalHandler().
// If an application is subscribing to a single with subscribeToSignal(),
// this function is doomed to fail. If a successful call to
// setSignalHandler() has been made withoutut unsetSingalHandler() called
// yet, a subsequence call to subscribeToSignal() is doomed to fail too.
// These two different interfaces are mutually exclusive.
static int setSignalHandler (int sig, SignalHandler sighr);
static int unsetSignalHandler (int sig);
protected:
static int set_signal_handler_no_mutex (int sig, SignalHandler sighr);
static int unset_signal_handler_no_mutex (int sig);