mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-16 22:02:58 -06:00
62 lines
1.3 KiB
C++
62 lines
1.3 KiB
C++
#ifndef _Signals_Signals_h_
|
|
#define _Signals_Signals_h_
|
|
|
|
#include <CtrlCore/CtrlCore.h>
|
|
|
|
using namespace Upp;
|
|
|
|
class TSignals
|
|
{
|
|
friend TSignals &Signals(void);
|
|
friend void ::_SignalHandler(int, siginfo_t *, void *);
|
|
|
|
private:
|
|
|
|
// flag indicating that the process instance has been stored on file
|
|
bool StoredInstance;
|
|
String LockName;
|
|
|
|
// signal/handlers map
|
|
ArrayMap<int, Callback> CallbackMap;
|
|
|
|
// costruttore
|
|
TSignals();
|
|
|
|
// dispatch signals
|
|
void Dispatch(int sig, siginfo_t *info, void *v);
|
|
|
|
// creates lock file name based on user name, app name and display
|
|
String CreateLockName(void);
|
|
|
|
public:
|
|
|
|
// distruttore
|
|
~TSignals();
|
|
|
|
// add a signal handler
|
|
bool Handle(int sig, Callback const &cb);
|
|
|
|
// removes a signal handler
|
|
bool Unhandle(int sig);
|
|
|
|
// stores process info on filesystem
|
|
// allowing other process to communicate with it
|
|
bool StoreInstance(void);
|
|
|
|
// checks whether another instance of this process is running
|
|
bool IsOtherInstanceRunning(void);
|
|
|
|
// sends a signal to another process
|
|
bool Send(int sig, int procId);
|
|
|
|
// sends a signal to another running instance of this app
|
|
bool Send(int sig);
|
|
|
|
}; // END Class TSignals
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
// Global signals access
|
|
TSignals &Signals(void);
|
|
|
|
|
|
#endif
|