From eb5c0a90e7d96325cfc537629bef769448eb9b71 Mon Sep 17 00:00:00 2001 From: Jianzhou Zhao Date: Wed, 3 Feb 2021 17:23:32 +0000 Subject: [PATCH] [dfsan] Test IGN and DFL for sigaction Reviewed-by: morehouse Differential Revision: https://reviews.llvm.org/D95957 --- compiler-rt/test/dfsan/custom.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/compiler-rt/test/dfsan/custom.cpp b/compiler-rt/test/dfsan/custom.cpp index 94ca7a82a825..9129eff72bae 100644 --- a/compiler-rt/test/dfsan/custom.cpp +++ b/compiler-rt/test/dfsan/custom.cpp @@ -847,10 +847,23 @@ void test_sigaction() { struct sigaction oldact; assert(0 == sigaction(SIGUSR1, &newact_with_sighandler, &oldact)); assert(oldact.sa_sigaction == SignalAction); + assert(oldact.sa_flags & SA_SIGINFO); + + // Set SIG_IGN or SIG_DFL, and check the previous one is expected. + newact_with_sighandler.sa_handler = SIG_IGN; + assert(0 == sigaction(SIGUSR1, &newact_with_sighandler, &oldact)); + assert(oldact.sa_handler == SignalHandler); + assert((oldact.sa_flags & SA_SIGINFO) == 0); + + newact_with_sighandler.sa_handler = SIG_DFL; + assert(0 == sigaction(SIGUSR1, &newact_with_sighandler, &oldact)); + assert(oldact.sa_handler == SIG_IGN); + assert((oldact.sa_flags & SA_SIGINFO) == 0); // Restore sigaction to the orginal setting, check the last one is SignalHandler assert(0 == sigaction(SIGUSR1, &origin_act, &oldact)); - assert(oldact.sa_handler == SignalHandler); + assert(oldact.sa_handler == SIG_DFL); + assert((oldact.sa_flags & SA_SIGINFO) == 0); } void test_signal() {