From 8daa83a594a2e98f39d764422bfbdbc62c9efd44 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 19:20:00 +0200 Subject: Adding upstream version 2:4.20.0+dfsg. Signed-off-by: Daniel Baumann --- ctdb/tests/src/sigcode.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 ctdb/tests/src/sigcode.c (limited to 'ctdb/tests/src/sigcode.c') diff --git a/ctdb/tests/src/sigcode.c b/ctdb/tests/src/sigcode.c new file mode 100644 index 0000000..9e5ed81 --- /dev/null +++ b/ctdb/tests/src/sigcode.c @@ -0,0 +1,120 @@ +/* + Portability layer for signal codes + + Copyright (C) Amitay Isaacs 2018 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see . +*/ + +/* + * These signals are as listed in POSIX standard + * IEEE Std 1003.1-2017 (Revision of IEEE Std 1003.1-2008) + */ + +#include "replace.h" +#include "system/wait.h" + +struct { + const char *label; + int code; +} sig_codes[] = { + { "SIGABRT", SIGABRT }, + { "SIGALRM", SIGALRM }, + { "SIBGUS", SIGBUS }, + { "SIGCHLD", SIGCHLD }, + { "SIGCONT", SIGCONT }, + { "SIGFPE", SIGFPE }, + { "SIGHUP", SIGHUP }, + { "SIGILL", SIGILL }, + { "SIGINT", SIGINT }, + { "SIGKILL", SIGKILL }, + { "SIGPIPE", SIGPIPE }, + { "SIGQUIT", SIGQUIT }, + { "SIGSEGV", SIGSEGV }, + { "SIGSTOP", SIGSTOP }, + { "SIGTERM", SIGTERM }, + { "SIGTSTP", SIGTSTP }, + { "SIGTTIN", SIGTTIN }, + { "SIGTTOU", SIGTTOU }, + { "SIGUSR1", SIGUSR1 }, + { "SIGUSR2", SIGUSR2 }, + { "SIGTRAP", SIGTRAP }, + { "SIGURG", SIGURG }, + { "SIGXCPU", SIGXCPU }, + { "SIGXFSZ", SIGXFSZ }, + +}; + +static void dump(void) +{ + size_t i; + + for (i=0; i\n", argv[0]); + exit(1); + } + + if (strcmp(argv[1], "dump") == 0) { + dump(); + } else { + code = strtol(argv[1], &endptr, 0); + if (*endptr == '\0') { + match_code(code); + } else { + match_label(argv[1]); + } + } + + exit(0); +} -- cgit v1.2.3