Below is the sample code --

#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include <string.h>

int main()
{
        int retval = -1;
    sigset_t  allsig, oldsig;

        printf("sizeof(sigset_t) = %d\n", sizeof(sigset_t));

    sigfillset (&allsig);
    retval = pthread_sigmask (SIG_SETMASK, &allsig, &oldsig);
        printf("SIG_SETMASK = %d\n", SIG_SETMASK);
    if (retval < 0)
    {
        printf("pthread_sigmask(): %s, errno = %d, retval = %d\n",
strerror(errno), errno, retval);
//        return -1;
    }

    retval = pthread_sigmask (SIG_SETMASK, &oldsig, 0);
    if (retval != 0)
    {
        printf("Restore sigmask: %s, errno = %d, retval = %d\n",
strerror(errno), errno, retval);
//        return -1;
    }

        return 0;
}

When I run this code on ADP1, I get following output --

sizeof(sigset_t) = 4
SIG_SETMASK = 2
pthread_sigmask(): Invalid argument, errno = 22, retval = -1
Restore sigmask: Invalid argument, errno = 22, retval = -1

strace shows that rt_sigprocmask() failed with error EINVAL

rt_sigprocmask(SIG_SETMASK, ~[], 0xbec7cbb4, 4) = -1 EINVAL (Invalid
argument)
rt_sigprocmask(SIG_SETMASK, [STKFLT], NULL, 4) = -1 EINVAL (Invalid
argument)

In kernel it fails at 'if (sigsetsize != sizeof(sigset_t))' in
function rt_sigprocmask() in file kernel/signal.c .
Here size of sigset_t is 8 and size of sigsetsize is 4.

I looked at file arch/arm/include/asm/signal.h and found that size of
sigset_t is 8 ((_NSIG_WORDS=2)*(sizeof(unsigned long))).

Further analysis shows that in file libc/bionic/pthread.c last
argument is passed as (_NSIG / 8) and _NSIG(==NSIG) is defined as 32
in libc/kernel/arch-arm/asm/signal.h.

Why does this inconsistency exist? Have I missed something or it is
like this and what do I need to do to get this working. I have tried
this on 2.6.27 and 2.6.29 both. The current output is on 2.6.29.

Please help.

Thanks
Ashutosh

--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-kernel
-~----------~----~----~----~------~----~------~--~---

Reply via email to