[libFuzzer] handle SIGTERM

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264338 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kostya Serebryany 2016-03-24 21:03:58 +00:00
parent 2f8286bd50
commit d32f138d30
4 changed files with 4 additions and 0 deletions

View 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;

View 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.")

View 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();

View 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");