summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
51873bd)
On a 2.6.24 Linux kernel, it appears that timer_settime() for
CLOCK_REALTIME is sometimes hanging for a random amount of time when
given a very small interval (we were using 1ns). Using 1ms seems to
be fine. Also I installed a 1-second timeout to catch hangs in the
future.
+static void timeout(int i)
+{
+ // timer_settime() has been known to hang, so just in case
+ // we install a 1-second timeout (see #2257)
+ exit(99);
+}
+
int main(int argc, char *argv[])
{
int main(int argc, char *argv[])
{
+ action.sa_handler = timeout;
+ action.sa_flags = 0;
+ sigemptyset(&action.sa_mask);
+ if (sigaction(SIGALRM, &action, NULL) == -1) {
+ fprintf(stderr,"SIGALRM problem\n");
+ exit(3);
+ }
+ alarm(1);
+
if (timer_create(CLOCK_PROCESS_CPUTIME_ID, &ev, &timer) != 0) {
fprintf(stderr,"No CLOCK_PROCESS_CPUTIME_ID timer\n");
exit(1);
if (timer_create(CLOCK_PROCESS_CPUTIME_ID, &ev, &timer) != 0) {
fprintf(stderr,"No CLOCK_PROCESS_CPUTIME_ID timer\n");
exit(1);
- fprintf(stderr,"no CLOCK_REALTIME signal\n");
+ fprintf(stderr,"no CLOCK_PROCESS_CPUTIME_ID signal\n");
}
it.it_value.tv_sec = 0;
}
it.it_value.tv_sec = 0;
- it.it_value.tv_nsec = 1;
+ it.it_value.tv_nsec = 1000000;
it.it_interval = it.it_value;
if (timer_settime(timer, 0, &it, NULL) != 0) {
fprintf(stderr,"settime problem\n");
it.it_interval = it.it_value;
if (timer_settime(timer, 0, &it, NULL) != 0) {
fprintf(stderr,"settime problem\n");