changing the ucontext structure in a sigaction handler

Kshitiz JAIN <[email protected]> Mon, 9 Aug 2004 14:01:55 +0530
Newsgroups gmane.linux.redhat.devel
Message-ID <[email protected]>
Hi all ,

I am trying to build a simple pre-emptive userspace thread library using makecontext,getcontext and swapcontext.

Is it safe to assign the ucontext_t struct passed in a sighandler with a ucontext_t struct created using getcontext ?

I am currently using Redhat Linux 7.3 with gcc 2.96 .

If anybody has any idea regarding what can be the potential problem with 
such usage ? 

Regards
Kshitiz

eg. 

static void handler_sigalrm(int sig ,siginfo_t  *sip ,void *arg) {
  ucontext_t * uap = (ucontext_t *)arg;
  int x;
  current_thread = *uap; // current_thread and other_thread are global
  *uap = other_thread;   // object of type ucontext_t
}