[OT] Question about nanosleep

Simon 'corecode' Schubert corecode at fs.ei.tum.de
Sun May 3 14:24:31 PDT 2009


walt wrote:
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);
        }
        int
        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?
Yes, it does.  There was just a bug in its code for signals.  Fixed in 
55d25c8782a76b25372313a908dff0a66d6ff342.

cheers
  simon
--
  <3 the future  +++  RENT this banner advert  +++   ASCII Ribbon   /"\
  rock the past  +++  space for low €€€ NOW!1  +++     Campaign     \ /
Party Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \
Dude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \





More information about the Users mailing list