mirror of
https://github.com/itay-grudev/SingleApplication.git
synced 2025-01-15 17:02:06 +08:00
Now handling all relevant signals
New handled signals are: SIGHUP, SIGQUIT, SIGBUS, SIGSYS, SIGPIPE, SIGALRM, SIGXCPU, SIGXFSZ
This commit is contained in:
parent
34b17f3c8f
commit
c5ea3f6d30
22
README.md
22
README.md
@ -54,14 +54,22 @@ Implementation
|
|||||||
--------------
|
--------------
|
||||||
The library is implemented with a QSharedMemory block which is thread safe and guarantees a race condition will not occur. It also uses a QLocalSocket to notify the main process that a new instance had been spawned and thus invoke the `showUp()` signal.
|
The library is implemented with a QSharedMemory block which is thread safe and guarantees a race condition will not occur. It also uses a QLocalSocket to notify the main process that a new instance had been spawned and thus invoke the `showUp()` signal.
|
||||||
|
|
||||||
To handle an issue on `*nix` systems, where the operating system owns the shared memory block and if the program crashes the memory remains untouched, the library binds to the following signals and closes the program with error code = `128 + signum` where signum is the number representation of the signal listed below. Handling the signal is required in order to safely delete the `QSharedMemory` block.
|
To handle an issue on `*nix` systems, where the operating system owns the shared memory block and if the program crashes the memory remains untouched, the library binds to the following signals and closes the program with error code = `128 + signum` where signum is the number representation of the signal listed below. Handling the signal is required in order to safely delete the `QSharedMemory` block. Each of these signals are potentially lethal and will results in process termination.
|
||||||
|
|
||||||
* `SIGINT ` - `2`
|
* `SIGHUP` - `1`, Hangup.
|
||||||
* `SIGILL ` - `4`
|
* `SIGINT` - `2`, Terminal interrupt signal
|
||||||
* `SIGABRT` - `6`
|
* `SIGQUIT` - `3`, Terminal quit signal.
|
||||||
* `SIGFPE ` - `8`
|
* `SIGILL` - `4`, Illegal instruction.
|
||||||
* `SIGSEGV` - `11`
|
* `SIGABRT` - `6`, Process abort signal.
|
||||||
* `SIGTERM` - `15`
|
* `SIGBUS` - `7`, Access to an undefined portion of a memory object.
|
||||||
|
* `SIGFPE` - `8`, Erroneous arithmetic operation (such as division by zero).
|
||||||
|
* `SIGSEGV` - `11`, Invalid memory reference.
|
||||||
|
* `SIGSYS` - `12`, Bad system call.
|
||||||
|
* `SIGPIPE` - `13`, Write on a pipe with no one to read it.
|
||||||
|
* `SIGALRM` - `14`, Alarm clock.
|
||||||
|
* `SIGTERM` - `15`, Termination signal.
|
||||||
|
* `SIGXCPU` - `24`, CPU time limit exceeded.
|
||||||
|
* `SIGXFSZ` - `25`, File size limit exceeded.
|
||||||
|
|
||||||
|
|
||||||
License
|
License
|
||||||
|
@ -43,12 +43,20 @@ public:
|
|||||||
}
|
}
|
||||||
// Handle any further termination signals to ensure the
|
// Handle any further termination signals to ensure the
|
||||||
// QSharedMemory block is deleted even if the process crashes
|
// QSharedMemory block is deleted even if the process crashes
|
||||||
signal(SIGSEGV, SingleApplicationPrivate::terminate);
|
signal(SIGHUP, SingleApplicationPrivate::terminate); // 1
|
||||||
signal(SIGABRT, SingleApplicationPrivate::terminate);
|
signal(SIGINT, SingleApplicationPrivate::terminate); // 2
|
||||||
signal(SIGFPE, SingleApplicationPrivate::terminate);
|
signal(SIGQUIT, SingleApplicationPrivate::terminate); // 3
|
||||||
signal(SIGILL, SingleApplicationPrivate::terminate);
|
signal(SIGILL, SingleApplicationPrivate::terminate); // 4
|
||||||
signal(SIGINT, SingleApplicationPrivate::terminate);
|
signal(SIGABRT, SingleApplicationPrivate::terminate); // 6
|
||||||
signal(SIGTERM, SingleApplicationPrivate::terminate);
|
signal(SIGBUS, SingleApplicationPrivate::terminate); // 7
|
||||||
|
signal(SIGFPE, SingleApplicationPrivate::terminate); // 8
|
||||||
|
signal(SIGSEGV, SingleApplicationPrivate::terminate); // 11
|
||||||
|
signal(SIGSYS, SingleApplicationPrivate::terminate); // 12
|
||||||
|
signal(SIGPIPE, SingleApplicationPrivate::terminate); // 13
|
||||||
|
signal(SIGALRM, SingleApplicationPrivate::terminate); // 14
|
||||||
|
signal(SIGTERM, SingleApplicationPrivate::terminate); // 15
|
||||||
|
signal(SIGXCPU, SingleApplicationPrivate::terminate); // 24
|
||||||
|
signal(SIGXFSZ, SingleApplicationPrivate::terminate); // 25
|
||||||
}
|
}
|
||||||
|
|
||||||
static void terminate(int signum)
|
static void terminate(int signum)
|
||||||
|
Loading…
Reference in New Issue
Block a user