mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-29 09:48:49 +08:00
mdbx-testing: минимальная обработка SIGINT
/SIGTERM
/SIGHUP
/SIGQUIT
для прозрачности прерываний в логах.
This commit is contained in:
parent
2c919c0efe
commit
6067ba5f9d
@ -342,6 +342,12 @@ static void handler_SIGCHLD(int signum) {
|
|||||||
++sigalarm_head;
|
++sigalarm_head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::atomic_int sigbreak;
|
||||||
|
static void handler_SIGBREAK(int signum) {
|
||||||
|
(void)signum;
|
||||||
|
++sigbreak;
|
||||||
|
}
|
||||||
|
|
||||||
int osal_delay(unsigned seconds) { return sleep(seconds) ? errno : 0; }
|
int osal_delay(unsigned seconds) { return sleep(seconds) ? errno : 0; }
|
||||||
|
|
||||||
int osal_actor_start(const actor_config &config, mdbx_pid_t &pid) {
|
int osal_actor_start(const actor_config &config, mdbx_pid_t &pid) {
|
||||||
@ -349,6 +355,17 @@ int osal_actor_start(const actor_config &config, mdbx_pid_t &pid) {
|
|||||||
if (children.empty()) {
|
if (children.empty()) {
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
memset(&act, 0, sizeof(act));
|
memset(&act, 0, sizeof(act));
|
||||||
|
act.sa_handler = handler_SIGBREAK;
|
||||||
|
sigaction(SIGTERM, &act, nullptr);
|
||||||
|
sigaction(SIGHUP, &act, nullptr);
|
||||||
|
sigaction(SIGINT, &act, nullptr);
|
||||||
|
sigaction(SIGQUIT, &act, nullptr);
|
||||||
|
#ifdef SIGXCPU
|
||||||
|
sigaction(SIGXCPU, &act, nullptr);
|
||||||
|
#endif
|
||||||
|
#ifdef SIGXFSZ
|
||||||
|
sigaction(SIGXFSZ, &act, nullptr);
|
||||||
|
#endif
|
||||||
act.sa_handler = handler_SIGCHLD;
|
act.sa_handler = handler_SIGCHLD;
|
||||||
sigaction(SIGCHLD, &act, nullptr);
|
sigaction(SIGCHLD, &act, nullptr);
|
||||||
sigaction(SIGALRM, &act, nullptr);
|
sigaction(SIGALRM, &act, nullptr);
|
||||||
@ -500,7 +517,7 @@ int osal_actor_poll(mdbx_pid_t &pid, unsigned timeout) {
|
|||||||
sigalarm_tail = sigalarm_head /* reset timeout flag */;
|
sigalarm_tail = sigalarm_head /* reset timeout flag */;
|
||||||
|
|
||||||
int options = WNOHANG;
|
int options = WNOHANG;
|
||||||
if (timeout) {
|
if (timeout && !sigbreak) {
|
||||||
alarm((timeout > INT_MAX) ? INT_MAX : timeout);
|
alarm((timeout > INT_MAX) ? INT_MAX : timeout);
|
||||||
options = 0;
|
options = 0;
|
||||||
}
|
}
|
||||||
@ -573,7 +590,7 @@ int osal_actor_poll(mdbx_pid_t &pid, unsigned timeout) {
|
|||||||
if (err != EINTR)
|
if (err != EINTR)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
return 0 /* timeout */;
|
return sigbreak ? EINTR : 0 /* timeout */;
|
||||||
}
|
}
|
||||||
|
|
||||||
void osal_yield(void) {
|
void osal_yield(void) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user