This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/17168] Can GLibc expose futex now?


https://sourceware.org/bugzilla/show_bug.cgi?id=17168

--- Comment #2 from Steven Stewart-Gallus <sstewartgallus00 at mylangara dot bc.ca> ---
I'm confused, in the source in nptl/nptl-init.c the signal handler is
not set with the flag for the SA_RESTART and so I should be able to
simply handle pthread_cancel by waiting for EINTR and then using
pthread_testcancel? However, pthread_cancel only seems to send the
signal when asynchronous cancels are enabled and not for deferred
cancels?

The source:

  struct sigaction sa;
  sa.sa_sigaction = sigcancel_handler;
  sa.sa_flags = SA_SIGINFO;
  __sigemptyset (&sa.sa_mask);

  (void) __libc_sigaction (SIGCANCEL, &sa, NULL);

The possible workaround:

static errno_t futex_wait(int *uaddr, int val, struct timespec const *timeout)
{
    int xx = syscall(__NR_futex, (intptr_t)uaddr, (intptr_t)FUTEX_WAIT,
                     (intptr_t)val,
                     (intptr_t)timeout);
    if (xx < 0) {
        errno_t errnum = errno;
        if (EINTR == errnum) {
            pthread_testcancel();
        }
        return errnum;
    }

    return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]