Skip to content

Commit

Permalink
[libfuzzer] use timer_create() instead of setitimer() for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
MinxuanZ committed Sep 27, 2024
1 parent 0df8880 commit 472761f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,16 @@ bool ExecuteCommand(const Command &Cmd, std::string *CmdOutput) {
}

void SetTimer(int Seconds) {
struct itimerval T {
timer_t timerid;
struct itimerspec T {
{Seconds, 0}, { Seconds, 0 }
};
if (setitimer(ITIMER_REAL, &T, nullptr)) {
Printf("libFuzzer: setitimer failed with %d\n", errno);
if (timer_create(CLOCK_REALTIME, NULL, &timerid) == -1) {
Printf("libFuzzer: timer_create failed with %d\n", errno);
exit(1);
}
if (timer_settime(timerid, 0, &T, NULL) == -1) {
Printf("libFuzzer: timer_settime failed with %d\n", errno);
exit(1);
}
SetSigaction(SIGALRM, AlarmHandler);
Expand Down

0 comments on commit 472761f

Please sign in to comment.