Skip to content

Commit c229365

Browse files
committed
[libfuzzer] use timer_create() instead of setitimer() for linux
1 parent 37ce3c2 commit c229365

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,16 @@ bool ExecuteCommand(const Command &Cmd, std::string *CmdOutput) {
104104
}
105105

106106
void SetTimer(int Seconds) {
107-
struct itimerval T {
107+
timer_t timerid;
108+
struct itimerspec T {
108109
{Seconds, 0}, { Seconds, 0 }
109110
};
110-
if (setitimer(ITIMER_REAL, &T, nullptr)) {
111-
Printf("libFuzzer: setitimer failed with %d\n", errno);
111+
if (timer_create(CLOCK_REALTIME, NULL, &timerid) == -1) {
112+
Printf("libFuzzer: timer_create failed with %d\n", errno);
113+
exit(1);
114+
}
115+
if (timer_settime(timerid, 0, &T, NULL) == -1) {
116+
Printf("libFuzzer: timer_settime failed with %d\n", errno);
112117
exit(1);
113118
}
114119
SetSigaction(SIGALRM, AlarmHandler);

0 commit comments

Comments
 (0)