Skip to content

Commit

Permalink
sighook: Ignore sigaction() errors in atsigexit()
Browse files Browse the repository at this point in the history
This fixes bfs under Valgrind, which reserves SIGRTMAX for its own use.
  • Loading branch information
tavianator committed Jun 7, 2024
1 parent e93a1dc commit a01cfac
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/sighook.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,24 +565,20 @@ struct sighook *sighook(int sig, sighook_fn *fn, void *arg, enum sigflags flags)
struct sighook *atsigexit(sighook_fn *fn, void *arg) {
mutex_lock(&sigmutex);

struct sighook *ret = NULL;

for (size_t i = 0; i < countof(FATAL_SIGNALS); ++i) {
if (siginit(FATAL_SIGNALS[i]) != 0) {
goto done;
}
// Ignore errors; atsigexit() is best-effort anyway and things
// like sanitizer runtimes or valgrind may reserve signals for
// their own use
siginit(FATAL_SIGNALS[i]);
}

#ifdef SIGRTMIN
for (int i = SIGRTMIN; i <= SIGRTMAX; ++i) {
if (siginit(i) != 0) {
goto done;
}
siginit(i);
}
#endif

ret = sighook_impl(&rcu_exithooks, 0, fn, arg, 0);
done:
struct sighook *ret = sighook_impl(&rcu_exithooks, 0, fn, arg, 0);
mutex_unlock(&sigmutex);
return ret;
}
Expand Down

0 comments on commit a01cfac

Please sign in to comment.