All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] signal handling in Xenomai 2.6.0
@ 2012-02-15 16:03 Jeff Webb
  2012-02-15 16:23 ` Gilles Chanteperdrix
  0 siblings, 1 reply; 9+ messages in thread
From: Jeff Webb @ 2012-02-15 16:03 UTC (permalink / raw)
  To: Xenomai help

[-- Attachment #1: Type: text/plain, Size: 1570 bytes --]

I am not able to block signals using pthread_sigmask or sigprocmask on my Xenomai 2.6.0 system.  If I compile my test program without Xenomai, it works as I intended and blocks the requested signals.  If I compile it for Xenomai, the requested signals are not blocked.  After scratching my head for some time, I tried running the program on an older machine running Xenomai 2.5.5.2, and it worked as I intended and blocked the requested signals.  I have not tried upgrading the Xenomai 2.5.5.2 machine to 2.6.0 to see if the problem is somehow related to the hardware on the newer machine.  I haven't noticed any other problems with Xenomai 2.6.0 on the newer machine; the latency and performance appear to be what I would expect.

My test program is attached.  I printed the current thread in the signal handler, and thought that the output might be of interest.  This is output from the program running under Xenomai 2.6.0:

   $ ./sigtest
   main thread: 7f6ff32c8700
   mlockall returned 0
   sigaction returned 0
   pthread_sigmask returned 0
   ^Csignal handled in: 7f6ff32f2700
   end of main
   $

If I comment out the call topthread_sigmask, I get this output:

   $ ./sigtest
   main thread: 7f446ba09700
   mlockall returned 0
   sigaction returned 0
   pthread_sigmask returned 0
   ^Csignal handled in: 7f446ba09700
   end of main
   $

It appears to me that in the first case, the signal is being blocked in the main thread, but is being handled in another (shadow?) thread.

Can someone confirm that this code works on Xenomai 2.6.0?

Thanks,

Jeff Webb


[-- Attachment #2: sigtest.c --]
[-- Type: text/x-csrc, Size: 879 bytes --]

#include <stdio.h>
#include <pthread.h>
#include <signal.h>
#include <sys/mman.h>

sig_atomic_t abort_program = 0;

void signal_handler(int sig)
{
  abort_program = 1;
  printf("signal handled in: %lx\n", pthread_self());
}

int main(void)
{
    int err;
    struct sigaction action;
    sigset_t mask;

    printf("main thread: %lx\n", pthread_self());

    err = mlockall(MCL_CURRENT | MCL_FUTURE);
    printf("mlockall returned %d\n", err);

    action.sa_handler = signal_handler;
    sigemptyset(&action.sa_mask);
    action.sa_flags = 0;
    err = sigaction(SIGINT, &action, NULL);
    printf("sigaction returned %d\n", err);
    
    sigemptyset(&mask);
    sigaddset(&mask, SIGINT);
    err = pthread_sigmask(SIG_BLOCK, &mask, NULL);
    printf("pthread_sigmask returned %d\n", err);    

    while(!abort_program)
    {}

    printf("end of main\n");
  
    return 0;
}

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-17 22:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-15 16:03 [Xenomai-help] signal handling in Xenomai 2.6.0 Jeff Webb
2012-02-15 16:23 ` Gilles Chanteperdrix
2012-02-15 17:23   ` Jeff Webb
2012-02-23 22:02   ` [Xenomai-help] Real-time printf " Jeff Webb
2012-02-23 22:26     ` Gilles Chanteperdrix
2012-02-23 23:07       ` Jeff Webb
2012-02-23 23:14         ` Gilles Chanteperdrix
2012-04-15 17:42         ` Gilles Chanteperdrix
2012-04-17 22:22           ` Jeff Webb

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.