summaryrefslogtreecommitdiff
path: root/lib/fuzzer/FuzzerUtilPosix.cpp
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2017-11-09 20:30:19 +0000
committerKostya Serebryany <kcc@google.com>2017-11-09 20:30:19 +0000
commit5646b9ef2068f1577569226326f62d90e2de5f09 (patch)
tree2e561ae7a8c60e83555ca99bdd1589813f8b8ee2 /lib/fuzzer/FuzzerUtilPosix.cpp
parentc483d54d4a6d703121c3054a522f1eeb745287d2 (diff)
downloadcompiler-rt-5646b9ef2068f1577569226326f62d90e2de5f09.tar.gz
[libFuzzer] handle SIGUSR1/SIGUSR2 and try to exit grafully on these signals
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@317829 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/fuzzer/FuzzerUtilPosix.cpp')
-rw-r--r--lib/fuzzer/FuzzerUtilPosix.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/fuzzer/FuzzerUtilPosix.cpp b/lib/fuzzer/FuzzerUtilPosix.cpp
index 24c5ccc35..934b7aa98 100644
--- a/lib/fuzzer/FuzzerUtilPosix.cpp
+++ b/lib/fuzzer/FuzzerUtilPosix.cpp
@@ -40,6 +40,10 @@ static void InterruptHandler(int, siginfo_t *, void *) {
Fuzzer::StaticInterruptCallback();
}
+static void GracefulExitHandler(int, siginfo_t *, void *) {
+ Fuzzer::StaticGracefulExitCallback();
+}
+
static void FileSizeExceedHandler(int, siginfo_t *, void *) {
Fuzzer::StaticFileSizeExceedCallback();
}
@@ -98,6 +102,10 @@ void SetSignalHandler(const FuzzingOptions& Options) {
SetSigaction(SIGFPE, CrashHandler);
if (Options.HandleXfsz)
SetSigaction(SIGXFSZ, FileSizeExceedHandler);
+ if (Options.HandleUsr1)
+ SetSigaction(SIGUSR1, GracefulExitHandler);
+ if (Options.HandleUsr2)
+ SetSigaction(SIGUSR2, GracefulExitHandler);
}
void SleepSeconds(int Seconds) {