From 6067ba5f9d026d6c41298d51c434c5255435e7df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Tue, 5 Nov 2024 19:25:10 +0300 Subject: [PATCH] =?UTF-8?q?mdbx-testing:=20=D0=BC=D0=B8=D0=BD=D0=B8=D0=BC?= =?UTF-8?q?=D0=B0=D0=BB=D1=8C=D0=BD=D0=B0=D1=8F=20=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=BA=D0=B0=20`SIGINT`/`SIGTERM`/`SIGHUP`/`S?= =?UTF-8?q?IGQUIT`=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE=D0=B7=D1=80?= =?UTF-8?q?=D0=B0=D1=87=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D0=BF=D1=80=D0=B5?= =?UTF-8?q?=D1=80=D1=8B=D0=B2=D0=B0=D0=BD=D0=B8=D0=B9=20=D0=B2=20=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B0=D1=85.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/osal-unix.c++ | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/osal-unix.c++ b/test/osal-unix.c++ index df340c1c..2c099d85 100644 --- a/test/osal-unix.c++ +++ b/test/osal-unix.c++ @@ -342,6 +342,12 @@ static void handler_SIGCHLD(int signum) { ++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_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()) { struct sigaction 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; sigaction(SIGCHLD, &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 */; int options = WNOHANG; - if (timeout) { + if (timeout && !sigbreak) { alarm((timeout > INT_MAX) ? INT_MAX : timeout); options = 0; } @@ -573,7 +590,7 @@ int osal_actor_poll(mdbx_pid_t &pid, unsigned timeout) { if (err != EINTR) return err; } - return 0 /* timeout */; + return sigbreak ? EINTR : 0 /* timeout */; } void osal_yield(void) {