diff options
author | Simon Marlow <marlowsd@gmail.com> | 2008-05-16 13:00:45 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2008-05-16 13:00:45 +0000 |
commit | 4c5fd95d192cd1f592b2e9c644c32cb96206feeb (patch) | |
tree | 5c07593dbad61faaf7cce56b1b4069726791c338 /aclocal.m4 | |
parent | 51873bdac451ee4a7e4b2ebc26a8706c08eab8e1 (diff) | |
download | haskell-4c5fd95d192cd1f592b2e9c644c32cb96206feeb.tar.gz |
FIX #2257: timer_settime() hangs during configure
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.
Diffstat (limited to 'aclocal.m4')
-rw-r--r-- | aclocal.m4 | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/aclocal.m4 b/aclocal.m4 index 85a1ee20b2..0432ed354b 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1072,6 +1072,13 @@ static void handler(int i) tock = 1; } +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[]) { @@ -1092,6 +1099,15 @@ int main(int argc, char *argv[]) exit(3); } + 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); @@ -1116,7 +1132,7 @@ int main(int argc, char *argv[]) out: if (!tock) { - fprintf(stderr,"no CLOCK_REALTIME signal\n"); + fprintf(stderr,"no CLOCK_PROCESS_CPUTIME_ID signal\n"); exit(5); } @@ -1128,7 +1144,7 @@ out: } 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"); |