I'm trying to build octave from source, but its configure hangs on "checking for working nanosleep". Closer investigation shows that nanosleep itself works fine, but that the test also checks if it gets interrupted by first scheduling an interrupt with alarm(1). As this never happens, and the configure test askes for a huge sleep-period (which is a bit silly), it appears as if the test hangs.
I can reproduce this by simply compiling and running the code below, which is based on the conftest.c file that configure creates (see end of post).
I've tried to put APIC off, but that doesn't help. Of course, I'm not 100% sure this is a vbox issue, but I didn't find any relevant posts regarding ubuntu on this issue.
My host is Windows 7, latest Virtualbox 4.1.4.
Code: Select all
$ uname -a
Linux splinter-ubuntu64 2.6.38-11-generic #50-Ubuntu SMP Mon Sep 12 21:17:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
here is the test code
Code: Select all
#include <errno.h>
#include <limits.h>
#include <signal.h>
#if HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <time.h>
#include <unistd.h>
#include <stdio.h>
static void
check_for_SIGALRM (int sig)
{
if (sig != SIGALRM)
_exit (1);
}
int
main ()
{
static struct timespec ts_sleep;
static struct timespec ts_remaining;
static struct sigaction act;
if (! nanosleep)
return 2;
act.sa_handler = check_for_SIGALRM;
sigemptyset (&act.sa_mask);
sigaction (SIGALRM, &act, NULL);
ts_sleep.tv_sec=12; /* changed this to 2 secs (original test uses MAX_INT) */
ts_sleep.tv_nsec = 999999999;
alarm (1);
if (nanosleep (&ts_sleep, &ts_remaining) != -1)
{
printf("\nAfter nanosleep, but no interrupt\n"); return 4;
}
else
printf("\nAfter nanosleep and interrupted\n");
if (errno != EINTR)
return 5;
if (ts_remaining.tv_sec <= ts_sleep.tv_sec - 10)
return 6;
return 0;
}
Code: Select all
$ gcc -g -o confnano confnano.c
$ time ./confnano
After nanosleep, but no interrupt
real 0m13.004s
user 0m0.000s
sys 0m0.000s
Code: Select all
$ time ./confnano
After nanosleep and interrupted
real 0m1.131s
user 0m0.030s
sys 0m0.031s
By the way, if I disable the nanosleep test in the configure script, it goes on to test sleep() in a similar fashion, and hangs there as well.