[libFuzzer] handle SIGTERM
authorKostya Serebryany <kcc@google.com>
Thu, 24 Mar 2016 21:03:58 +0000 (21:03 +0000)
committerKostya Serebryany <kcc@google.com>
Thu, 24 Mar 2016 21:03:58 +0000 (21:03 +0000)
llvm-svn: 264338

llvm/lib/Fuzzer/FuzzerDriver.cpp
llvm/lib/Fuzzer/FuzzerFlags.def
llvm/lib/Fuzzer/FuzzerInternal.h
llvm/lib/Fuzzer/FuzzerUtil.cpp

index a31d306..9be1b7f 100644 (file)
@@ -338,6 +338,7 @@ static int FuzzerDriver(const std::vector<std::string> &Args,
   if (Flags.handle_ill) SetSigIllHandler();
   if (Flags.handle_fpe) SetSigFpeHandler();
   if (Flags.handle_int) SetSigIntHandler();
+  if (Flags.handle_term) SetSigTermHandler();
 
   if (DoPlainRun) {
     Options.SaveArtifacts = false;
index 20ffa32..4504cff 100644 (file)
@@ -75,6 +75,7 @@ FUZZER_FLAG_INT(handle_abrt, 1, "If 1, try to intercept SIGABRT.")
 FUZZER_FLAG_INT(handle_ill, 1, "If 1, try to intercept SIGILL.")
 FUZZER_FLAG_INT(handle_fpe, 1, "If 1, try to intercept SIGFPE.")
 FUZZER_FLAG_INT(handle_int, 1, "If 1, try to intercept SIGINT.")
+FUZZER_FLAG_INT(handle_term, 1, "If 1, try to intercept SIGTERM.")
 FUZZER_FLAG_INT(close_fd_mask, 0, "If 1, close stdout at startup; "
                                        "if 2, close stderr; if 3, close both.")
 
index 2ff1319..7200cbe 100644 (file)
@@ -92,6 +92,7 @@ void SetSigAbrtHandler();
 void SetSigIllHandler();
 void SetSigFpeHandler();
 void SetSigIntHandler();
+void SetSigTermHandler();
 std::string Base64(const Unit &U);
 int ExecuteCommand(const std::string &Command);
 size_t GetPeakRSSMb();
index 84c4983..d533561 100644 (file)
@@ -106,6 +106,7 @@ void SetSigAbrtHandler() { SetSigaction(SIGABRT, CrashHandler); }
 void SetSigIllHandler() { SetSigaction(SIGILL, CrashHandler); }
 void SetSigFpeHandler() { SetSigaction(SIGFPE, CrashHandler); }
 void SetSigIntHandler() { SetSigaction(SIGINT, InterruptHandler); }
+void SetSigTermHandler() { SetSigaction(SIGTERM, InterruptHandler); }
 
 int NumberOfCpuCores() {
   FILE *F = popen("nproc", "r");