mdbx-test: output the signal name if killed/coredumped.

Change-Id: I51e70daf89149ecbe72924fc9f105ea072574a23
This commit is contained in:
Leonid Yuriev 2021-04-14 15:03:51 +03:00
parent 958fd5b947
commit 28affe79d8
2 changed files with 161 additions and 5 deletions

View File

@ -2,6 +2,7 @@ aarch
abcdef
abf
abra
ABRT
abstime
ACI
acision
@ -32,6 +33,7 @@ allones
ALLPOSTMESSAGE
allthrough
alphabase
ALRM
altlinux
AMAX
amd
@ -159,6 +161,7 @@ CHECKOWNER
CHECKPID
chipitsine
chk
CHLD
chrono
ci
cifs
@ -1426,6 +1429,7 @@ searchdata
SEARCHENGINE
sebastien
segfault
SEGV
sema
sembuf
semctl
@ -1459,23 +1463,45 @@ showinitializer
showned
shrinked
sideeffect
SIGABRT
sigaction
sigaddset
sigalarm
SIGALRM
SIGBUS
SIGCHLD
SIGCONT
sigemptyset
SIGEMT
SIGFPE
SIGHUP
SIGINT
SIGIO
SIGKILL
sigmask
SIGPIPE
SIGPOLL
sigprocmask
SIGPROF
SIGPWR
SIGQUIT
SIGSEGV
sigset
SIGSTKFLT
SIGSTOP
SIGSYS
SIGTERM
SIGTRAP
SIGTSTP
SIGTTIN
SIGTTOU
SIGURG
sigusr
SIGVTALRM
sigwait
SIGWINCH
SIGXCPU
SIGXFSZ
singlemode
singleprocess
sizeof
@ -1542,6 +1568,7 @@ stdio
stdlib
stdout
stepbystep
STKFLT
storz
stoull
strcasecmp
@ -1671,8 +1698,11 @@ trywait
tsan
tsd
tsize
TSTP
ttf
TTIN
ttl
TTOU
TVvqnwctdis
tw
twistylittlepassagesallalike
@ -1730,6 +1760,7 @@ updation
upsert
UPSERTING
upsertion
URG
url
usec
usedbytes
@ -1782,6 +1813,7 @@ vromanov
Vrq
vscprintf
vsnprintf
VTALRM
vvn
vvnw
vvv
@ -1844,6 +1876,7 @@ WSL
wsl
wstr
wstring
WTERMSIG
WUNTRACED
www
WX
@ -1852,10 +1885,12 @@ xappend
xargs
xcode
XCONCAT
XCPU
xcursor
xdata
xf
xflags
XFSZ
xhtml
xkeep
XLB

View File

@ -393,6 +393,110 @@ void osal_killall_actors(void) {
}
}
static const char *signal_name(const int sig) {
if (sig == SIGHUP)
return "HUP";
if (sig == SIGINT)
return "INT";
if (sig == SIGQUIT)
return "QUIT";
if (sig == SIGILL)
return "ILL";
if (sig == SIGTRAP)
return "TRAP";
if (sig == SIGABRT)
return "ABRT";
if (sig == SIGBUS)
return "BUS";
if (sig == SIGKILL)
return "KILL";
if (sig == SIGUSR1)
return "USR1";
if (sig == SIGSEGV)
return "SEGV";
if (sig == SIGUSR2)
return "USR2";
if (sig == SIGPIPE)
return "PIPE";
if (sig == SIGALRM)
return "ALRM";
if (sig == SIGTERM)
return "TERM";
if (sig == SIGCHLD)
return "CHLD";
if (sig == SIGCONT)
return "CONT";
if (sig == SIGSTOP)
return "STOP";
#ifdef SIGPOLL
if (sig == SIGPOLL)
return "POLL";
#endif
#ifdef SIGFPE
if (sig == SIGFPE)
return "FPE";
#endif
#ifdef SIGEMT
if (sig == SIGEMT)
return "EMT";
#endif
#ifdef SIGSTKFLT
if (sig == SIGSTKFLT)
return "STKFLT";
#endif
#ifdef SIGTSTP
if (sig == SIGTSTP)
return "TSTP";
#endif
#ifdef SIGTTIN
if (sig == SIGTTIN)
return "TTIN";
#endif
#ifdef SIGTTOU
if (sig == SIGTTOU)
return "TTOU";
#endif
#ifdef SIGURG
if (sig == SIGURG)
return "URG";
#endif
#ifdef SIGXCPU
if (sig == SIGXCPU)
return "XCPU";
#endif
#ifdef SIGXFSZ
if (sig == SIGXFSZ)
return "XFSZ";
#endif
#ifdef SIGVTALRM
if (sig == SIGVTALRM)
return "VTALRM";
#endif
#ifdef SIGPROF
if (sig == SIGPROF)
return "PROF";
#endif
#ifdef SIGWINCH
if (sig == SIGWINCH)
return "WINCH";
#endif
#ifdef SIGIO
if (sig == SIGIO)
return "IO";
#endif
#ifdef SIGPWR
if (sig == SIGPWR)
return "PWR";
#endif
#ifdef SIGSYS
if (sig == SIGSYS)
return "SYS";
#endif
static char buf[32];
snprintf(buf, sizeof(buf), "%u", sig);
return buf;
}
int osal_actor_poll(mdbx_pid_t &pid, unsigned timeout) {
static sig_atomic_t sigalarm_tail;
alarm(0) /* cancel prev timeout */;
@ -420,11 +524,28 @@ int osal_actor_poll(mdbx_pid_t &pid, unsigned timeout) {
if (WIFEXITED(status))
children[pid] =
(WEXITSTATUS(status) == EXIT_SUCCESS) ? as_successful : as_failed;
else if (WCOREDUMP(status))
children[pid] = as_coredump;
else if (WIFSIGNALED(status))
children[pid] = as_killed;
else if (WIFSTOPPED(status))
else if (WIFSIGNALED(status)) {
#ifdef WCOREDUMP
if (WCOREDUMP(status))
children[pid] = as_coredump;
else
#endif /* WCOREDUMP */
switch (WTERMSIG(status)) {
case SIGABRT:
case SIGBUS:
case SIGFPE:
case SIGILL:
case SIGSEGV:
log_notice("child pid %u terminated by SIG%s", pid,
signal_name(WTERMSIG(status)));
children[pid] = as_coredump;
break;
default:
log_notice("child pid %u killed by SIG%s", pid,
signal_name(WTERMSIG(status)));
children[pid] = as_killed;
}
} else if (WIFSTOPPED(status))
children[pid] = as_debugging;
else if (WIFCONTINUED(status))
children[pid] = as_running;