Skip to content

Commit ca52e9c

Browse files
committed
Call nanosleep instead of sleep in polling loop
This avoids unnecessary rt_sigprocmask and rt_sigaction system calls.
1 parent 6aba92d commit ca52e9c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/mbpfan.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <stdlib.h>
3333
#include <unistd.h>
3434
#include <string.h>
35+
#include <time.h>
3536
#include <math.h>
3637
#include <syslog.h>
3738
#include <stdbool.h>
@@ -571,6 +572,11 @@ void mbpfan()
571572
}
572573
}
573574

574-
sleep(polling_interval);
575+
// call nanosleep instead of sleep to avoid rt_sigprocmask and
576+
// rt_sigaction
577+
struct timespec ts;
578+
ts.tv_sec = polling_interval;
579+
ts.tv_nsec = 0;
580+
nanosleep(&ts, NULL);
575581
}
576582
}

0 commit comments

Comments
 (0)