DragonFly users List (threaded) for 2009-05
DragonFly BSD
DragonFly users List (threaded) for 2009-05
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

[OT] Question about nanosleep

From: walt <wa1ter@xxxxxxxxxxxxx>
Date: Sat, 2 May 2009 17:37:27 -0700

This question began when my gnome desktop on a linux amd64 machine started
behaving badly while the same gnome packages on an x86 machine work perfectly.

While poking around for clues I noticed that a configure script fails on the
amd64 machine but works perfectly on the x86.  I'm not sure if this is the
cause of my gnome malfunction, but here is the failing 'configure' code:

$ cat conftest.c
        #include <errno.h>
        #include <limits.h>
        #include <signal.h>
        #include <sys/time.h>
        #include <time.h>
        #include <unistd.h>
        #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* watch for linewrap! */
        #define TYPE_MAXIMUM(t)           ((t) (! TYPE_SIGNED (t)
? (t) -1                : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))

        static void
        check_for_SIGALRM (int sig)
          if (sig != SIGALRM)
            _exit (1);

        main ()
          static struct timespec ts_sleep;
          static struct timespec ts_remaining;
          static struct sigaction act;
          if (! nanosleep)
            return 1;
          act.sa_handler = check_for_SIGALRM;
          sigemptyset (&act.sa_mask);
          sigaction (SIGALRM, &act, NULL);
          ts_sleep.tv_sec = 0;
          ts_sleep.tv_nsec = 1;
          alarm (1);
          if (nanosleep (&ts_sleep, NULL) != 0)
            return 1;
          ts_sleep.tv_sec = TYPE_MAXIMUM (time_t);
          ts_sleep.tv_nsec = 999999999;
          alarm (1);
          if (nanosleep (&ts_sleep, &ts_remaining) == -1 && errno == EINTR
              && TYPE_MAXIMUM (time_t) - 10 < ts_remaining.tv_sec)
            return 0;
          return 119;

I compiled the code on DragonFly-HEAD for comparison and I was surpised to see
that nanosleep apparently doesn't work on DragonFly:  the program returns 119,
just like on my misbehaving linux amd64 machine.

Can someone give me the big picture here?  Does DragonFly implement nanosleep,
and if not, why not?


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]