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

pthreads and sigaltstack on i386



I'm using Debian potato.  I can't get this program to
use sigaltstack and pthreads at the same time on i386.
 I get a SIGSEGV in pthread_sighandler. The program
works fine on Alpha Linux and Solaris. Is this a known
i386 problem?  Is there a cure?

Thanks,
Bob

---
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>

int handler_called = 0;

void
handler(int sig)
{
  handler_called = 1;
}

int
main()
{
  sigset_t sigs, osigs;
  struct sigaction sa, osa;
  stack_t sas, osas;

  sigemptyset(&sigs);
  sigaddset(&sigs, SIGUSR1);
  sigprocmask(SIG_BLOCK, &sigs, &osigs);
    
  sa.sa_handler = handler;
  sa.sa_flags = SA_ONSTACK;
  sigemptyset(&sa.sa_mask);
  sigaction(SIGUSR1, &sa, &osa);

  sas.ss_sp = (char *)malloc(SIGSTKSZ);
  sas.ss_size = SIGSTKSZ;
  sas.ss_flags = 0;
  sigaltstack(&sas, &osas);

  kill(getpid(), SIGUSR1);
  sigfillset(&sigs);
  sigdelset(&sigs, SIGUSR1);
  while (!handler_called)
    sigsuspend(&sigs);    
}


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/



Reply to: