commit: e52c2e2e3d9ef35244e7b1e9c08428519e7ccbb9
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 29 11:55:27 2025 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec 29 11:55:27 2025 +0000
URL: https://gitweb.gentoo.org/proj/steve.git/commit/?id=e52c2e2e
Replace sigabbrev_np() for compatibility with musl
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
src/steve.cxx | 6 +++---
src/stevie.cxx | 2 +-
src/util.hxx | 18 ++++++++++++++++++
3 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/steve.cxx b/src/steve.cxx
index 25a6b50..b85b0d8 100644
--- a/src/steve.cxx
+++ b/src/steve.cxx
@@ -994,7 +994,7 @@ static void steve_handle_recheck(evutil_socket_t, short,
void *userdata) {
static void steve_handle_exit(evutil_socket_t signum, short, void *userdata) {
steve_state *state = static_cast<steve_state *>(userdata);
- std::print("Exiting on SIG{}\n", sigabbrev_np(signum));
+ std::print("Exiting on SIG{}\n", signal_name(signum));
if (event_base_loopbreak(state->evb) == -1) {
std::print(stderr, "event_base_loopbreak() failed, forcing hard
exit");
exit(1);
@@ -1005,11 +1005,11 @@ static event_ptr steve_new_signal_handler(steve_state
*state, int signum, event_
{
event_ptr ret{evsignal_new(state->evb, signum, handler, state),
event_free};
if (!ret) {
- std::print(stderr, "failed to initialize SIG{} handler",
sigabbrev_np(signum));
+ std::print(stderr, "failed to initialize SIG{} handler",
signal_name(signum));
return nullptr;
}
if (event_add(ret.get(), nullptr) == -1) {
- std::print(stderr, "failed to enable SIG{} handler",
sigabbrev_np(signum));
+ std::print(stderr, "failed to enable SIG{} handler",
signal_name(signum));
return nullptr;
}
return ret;
diff --git a/src/stevie.cxx b/src/stevie.cxx
index f58cad8..7f9fe8e 100644
--- a/src/stevie.cxx
+++ b/src/stevie.cxx
@@ -43,7 +43,7 @@ void signal_handler(int signum, siginfo_t *, void *)
{
if (pid != -1) {
std::print("stevie: passing signal SIG{} to child {}, repeat to
force termination\n",
- sigabbrev_np(signum), pid);
+ signal_name(signum), pid);
if (kill(pid, signum) == -1 && errno != ESRCH) {
perror("Unable to pass signal to child process");
exit(1);
diff --git a/src/util.hxx b/src/util.hxx
index 66f28ed..a816940 100644
--- a/src/util.hxx
+++ b/src/util.hxx
@@ -30,3 +30,21 @@ static bool arg_to_double(const char *optarg, double *out) {
!*endptr && errno == 0
);
}
+
+#define SIGSTR(x) case SIG##x: return #x
+
+static const char *signal_name(int signo)
+{
+ switch (signo) {
+ SIGSTR(HUP);
+ SIGSTR(INT);
+ SIGSTR(TERM);
+ SIGSTR(USR1);
+ SIGSTR(USR2);
+ default:
+ assert(0 && "not reached");
+ return "?";
+ }
+}
+
+#undef SIGSTR