[compiler-rt] [sanitizer_common] AND signals in BlockSignals instead of deleting (PR #113443)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 00:54:00 PDT 2024


================
@@ -0,0 +1,81 @@
+//===-- sanitizer_block_signals.cpp ---------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of sanitizer_common unit tests.
+//
+//===----------------------------------------------------------------------===//
+#include <signal.h>
+#include <stdio.h>
+
+#include "gtest/gtest.h"
+#include "sanitizer_common/sanitizer_linux.h"
+
+namespace __sanitizer {
+
+#if SANITIZER_LINUX
+volatile int received_sig = -1;
+
+void signal_handler(int signum) { received_sig = signum; }
+
+TEST(SanitizerCommon, BlockSignals) {
+  // No signals blocked
+  {
+    signal(SIGUSR1, signal_handler);
+    raise(SIGUSR1);
+    while (received_sig == -1) sleep(1);
+    EXPECT_EQ(received_sig, SIGUSR1);
+
+    received_sig = -1;
+    signal(SIGPIPE, signal_handler);
+    raise(SIGPIPE);
----------------
vitalybuka wrote:

do we need to sleep?

https://github.com/llvm/llvm-project/pull/113443


More information about the llvm-commits mailing list