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

thread with SIGSEGV



Hi all,

I saw a difference between Axis and standard implementation
of threads when they catch a SIGSEGV signal.

Example:

#include <stdio.h>
#include <signal.h>
#include <pthread.h>

void catch_signal(int n) {
  printf("thread %d got signal %d\n", getpid(), n);
  pthread_exit(0);
}

void *thread_child(void *param) {
  struct sigaction action;
  char *crash;
  action.sa_flags = 0;
  action.sa_handler = catch_signal;
  sigemptyset(&(action.sa_mask));
  if(sigaction(SIGSEGV, &action, NULL) < 0) {
    fprintf(stderr, "cannot set signal, %m\n");
    exit(1);
  }
  sleep(2);
  /* now raise SIGSEGV */
  crash = 0;
  *crash = 0;
  pthread_exit(0);
}
  

int main(int argc, char** argv) {
  pthread_t child;
  pthread_create(&child, NULL, thread_child, NULL);
  pthread_detach(child);
  while(1) {
    printf("father %d\n", getpid());
    sleep(1);
  }
}

With a PC-redhat:
> ./catchsig
father 4085
father 4085
thread 4087 got signal 11
father 4085
father 4085

With etrax board and cris-1.15.1:

> ./catchsig
father 67
father 67
father 67
father 67
father 67
Out of Memory: Killed process 67 (catchsig).
pid 67: killed by signal 15
> Out of Memory: Killed process 68 (catchsig).
Out of Memory: Killed process 69 (catchsig).
Out of Memory: Killed process 69 (catchsig).
Out of Memory: Killed process 69 (catchsig).
Out of Memory: Killed process 69 (catchsig).
Out of Memory: Killed process 69 (catchsig).
Out of Memory: Killed process 69 (catchsig).
Out of Memory: Killed process 69 (catchsig).
Out of Memory: Killed process 69 (catchsig).
:<27>Jan 1 0:3:32 kernel[0]: Out of Memory: Killed process 67
(catchsig).
0

How to explain this difference ?

Thanks for your advices.

Jerome Lefranc

-- 
-------------------------------------------------------------
Jerome LEFRANC           jerome.lefranc@xxxxxxx.com
XCell Technology         http://www.xcell.com
DECISION Europe, 75-85 rue Richelieu
85170 les Lucs sur Boulogne, FRANCE
Voice: +33 2 51 31 38 38,  Fax: +33 2 51 46 59 66
-------------------------------------------------------------